Integration to 3rd party tools
This section tries to give some hits how to integrate FlhCli into 3rd party monitoring tools.
LibreNMS
The best way to integrate FlhCli into LibreNMS is to utilize its Nagios plugins Services integration.
It is necessary to write a simple Nagios plugin that also provides the performance data (after "|" in the output line, no comma between multiple performance counters). The Nagios plugin runs flhcli with required parameters and translates the output to conform to Nagios plugin specification.
The flhcli
utility must be present somewhere on filesystem and must be executable by librenms user.
The plugins presented here expect that it is in /opt/flh
directory, together with flhcli.xml
configuration file (do not forget to make it readable by librenms user).
Some FlhCli commands provide --batch
parameter to make parsing easier. When it is used, the command
output is provided without any headers, additional spaces, comments, etc.
To enable Nagios services in LibreNMS, following code needs to be added to config.php:
$config['show_services'] = 1;
$config['nagios_plugins'] = "/usr/lib/nagios/plugins";
Follow the LibreNMS documentation but do not
add services-wrapper.py
to cron if you already have check-services.php
there, because that
would run the same service twice at the same time, which can degrade the results for some commands.
When the LibreNMS is configured, new menu "Services" apperars in the top panel and a new service must be created.
Device
field controls to which monitored device the service will belong. You should select the FortiGate you want to monitor.Type
is the name of the Nagios plugin without initial "check_" part.IP Address
is the device identification passed into the plugin. It can be whatever you want (not just the IP address), but device of the same name must be defined inflhcli.xml
file. Be careful as the plugins usually contain their own path to theflhcli.xml
file, which may not be the same one as if you run tests from CLI.Parameters
are additional parameters passed into the plugin and are specific for each plugin.
If the plugin returns more performance counters, LibreNMS will create a separate graph for each.
np6drops
(requires flhcli version >= 1.3)
Command np6drops supports the --batch
parameter which simplies the output for parsing:
$ /opt/flh/flhcli --config /opt/flh/flhcli.xml --name testdevice --stop-on-error np6drops --batch
[2020-06-01 19:11:50 +0200] Selected device "testdevice" xx.xxx.xx.xxx:22 (maximum 4 simultaneous connections)
[2020-06-01 19:11:50 +0200] Collecting data...
3 TPE_HPE 36159
2 TPE_HPE 35111
2 TPE_HPE 35075
3 TPE_HPE 35075
2 TPE_HPE 35079
3 TPE_HPE 35074
2 TPE_HPE 35088
3 TPE_HPE 35087
[...]
Example Nagios plugin for np6drops uses this parameter together
with --summarize
parameter to summarize the same counters from all NP6 chips to one line, and with
--iterations 1
and --interval 5s
parameters to only collect counters for five seconds and quit:
$ /opt/flh/flhcli --config /opt/flh/flhcli.xml --name testdevice --stop-on-error np6drops --batch --summarize --iterations 1 --interval 5s
[2020-06-01 19:15:53 +0200] Selected device "testdevice" xx.xxx.xx.xxx:22 (maximum 4 simultaneous connections)
[2020-06-01 19:15:53 +0200] Collecting data...
- TPE_HPE 71295
$
Following parameters are recognized when creating new LibreNMS Service:
-c <value>
Critical threshold. When the drop counter(s) is >= value, service reports "critical" state.-w <value>
Warning threshold. Wehn the drop counter(s) is bellow critical threshold but >= value, the service reports "warning" state.-r <regexp>
Regular expression on counter name. If not specified, all counters are collected, which may create too many graphs and slow the LibreNMS GUI down. Therefore use only counters that you are really interested in. Artifical counterTOTAL
can be used to get the number of all packets dropped on NP6(es) regardless of reason.
Example service parameters to collect and graph only TPE_HPE
drop counters with warning threshold set
to 1,000 packets per second and critical to 10,000 packets per second:
-w 1000 -c 10000 -r ^TPE_HPE$
Results in similar graphs plotted for device in Services submenu:
And using multiple counters:
-w 1000 -c 10000 -r ^TPE_HPE|TOTAL$
Results in:
Warning: It seems that all counters required to be graphed must be defined in the service since the very beggining.
LibreNMS does not seem to handle updated counters in the later stage. In that case it make sense
to use at least something like ^TPE_HPE|TOTAL$
. However, in that case the disadvantage is that the same
configured warning and critical threshold applies to each counter.