diff --git a/doc/Extensions/NFSen.md b/doc/Extensions/NFSen.md index 19ee26d160..e1f1dd19cf 100644 --- a/doc/Extensions/NFSen.md +++ b/doc/Extensions/NFSen.md @@ -9,8 +9,9 @@ The following is the configuration that can be used: ```php $config['nfsen_enable'] = 1; -$config['nfsen_split_char'] = "_"; -$config['nfsen_rrds'] = "/var/nfsen/profiles-stat/live/"; +$config['nfsen_split_char'] = '_'; +$config['nfsen_rrds'][] = '/var/nfsen/profiles-stat/live/'; +$config['nfsen_rrds'][] = '/var/nfsen/profiles-stat'; $config['nfsen_suffix'] = "_yourdomain_com"; ``` @@ -24,9 +25,25 @@ $config['nfsen_rrds'][] = '/var/nfsen/profiles-stat/sitea/'; $config['nfsen_rrds'][] = '/var/nfsen/profiles-stat/siteb/'; ``` +Although for most setups, it will look like below, with the profiles-stat/live directory being where it stores the general RRDs for data sources. + +```php +$config['nfsen_rrds'][] = '/var/nfsen/profiles-stat/live'; +``` + `$config['nfsen_split_char']` This value tells us what to replace the full stops `.` in the devices hostname with. `$config['nfsen_suffix']` This value will be removed from the domain name and can be useful if your rrd files are something like `host1.rrd` but your device hostname is `domain.host1.rrd`. You can then set $config['nfsen_suffix'] = 'domain'; +If you wish to render info for configure channels for a device, you need add the various profile-stat directories your system uses, which for most systems will be as below. + +```php +$config['nfsen_rrds'][] = '/var/nfsen/profiles-stat'; +``` + +When adding sources to nfsen.conf, it is important to use the hostname that matches what is configured in LibreNMS. + +When creating profiles under nfsen, be sure to use the hostname so it matches the name in LibreNMS. That is where channel data will be pulled from. + You should a new tab for the device called Nfsen. diff --git a/html/includes/graphs/device/nfsen_channel_common.inc.php b/html/includes/graphs/device/nfsen_channel_common.inc.php new file mode 100644 index 0000000000..8ae1be9300 --- /dev/null +++ b/html/includes/graphs/device/nfsen_channel_common.inc.php @@ -0,0 +1,44 @@ + $rrd_filename, + 'descr' => $flowtype, + 'ds' => $dsprefix.$flowtype + ); + } + d_echo($rrd_list); + } +} + +require 'includes/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/html/includes/graphs/device/nfsen_channel_flows.inc.php b/html/includes/graphs/device/nfsen_channel_flows.inc.php new file mode 100644 index 0000000000..cfa2d351ef --- /dev/null +++ b/html/includes/graphs/device/nfsen_channel_flows.inc.php @@ -0,0 +1,5 @@ + 'nfsen_flows', - 'Packets' => 'nfsen_packets', - 'Traffic' => 'nfsen_traffic', - ); +print_optionbar_start(); -foreach ($datas as $name => $type) { - $graph_title = $name; - $graph_type = 'device_'.$type; +$link_array = array( + 'page' => 'device', + 'device' => $device['device_id'], + 'tab' => 'nfsen', + ); - include 'includes/print-device-graph.php'; +echo generate_link('General', $link_array, array('nfsen' => 'general')); + +$printedChannel=false; +$nfsenHostname=str_replace('.', $config['nfsen_split_char'], $device['hostname']); +foreach ($config['nfsen_rrds'] as $nfsenDir) { + $hostDir=$nfsenDir.'/'.$nfsenHostname.'/'; + if (is_dir($hostDir)) { + $nfsenRRDchannelGlob=$hostDir.'*.rrd'; + foreach (glob($nfsenRRDchannelGlob) as $nfsenRRD) { + $channel = str_replace(array($hostDir, '.rrd'), '', $nfsenRRD); + + if (!$printedChannel) { + echo '|Channels:'; + $printedChannel=true; + } else { + echo ','; + } + + if ($vars['channel'] == $channel) { + $channelFilter=$hostDir.$channel.'-filter.txt'; + } + + echo generate_link($channel, $link_array, array('nfsen' => 'channel', 'channel' => $channel)); + } + } +} + +print_optionbar_end(); + +if (!$vars['nfsen']) { + $vars['nfsen'] = 'general'; +} + +if (is_file('pages/device/nfsen/'.mres($vars['nfsen']).'.inc.php')) { + include 'pages/device/nfsen/'.mres($vars['nfsen']).'.inc.php'; +} else { + include 'pages/device/nfsen/general.inc.php'; } $pagetitle[] = 'Netflow'; diff --git a/html/pages/device/nfsen/channel.inc.php b/html/pages/device/nfsen/channel.inc.php new file mode 100644 index 0000000000..dde7a58d58 --- /dev/null +++ b/html/pages/device/nfsen/channel.inc.php @@ -0,0 +1,22 @@ + 'nfsen_channel_flows', + 'Packets' => 'nfsen_channel_packets', + 'Traffic' => 'nfsen_channel_traffic', + ); + +if (isset($channelFilter)&&file_exists($channelFilter)) { + $chanelFilterContents=file_get_contents($channelFilter); + print_optionbar_start(); + print $vars['channel'].' Filter: '.$chanelFilterContents; + print_optionbar_end(); +} + +foreach ($datas as $name => $type) { + $graph_title = $name; + $graph_type = 'device_'.$type; + $graph_array['channel']=$vars['channel']; + + include 'includes/print-device-graph.php'; +} diff --git a/html/pages/device/nfsen/general.inc.php b/html/pages/device/nfsen/general.inc.php new file mode 100644 index 0000000000..f8c7c1bcec --- /dev/null +++ b/html/pages/device/nfsen/general.inc.php @@ -0,0 +1,14 @@ + 'nfsen_flows', + 'Packets' => 'nfsen_packets', + 'Traffic' => 'nfsen_traffic', + ); + +foreach ($datas as $name => $type) { + $graph_title = $name; + $graph_type = 'device_'.$type; + + include 'includes/print-device-graph.php'; +}