Setting up ICMP checks
What if we care only about the basic reachability of a host, such as a router or switch that is out of our control? ICMP ping (echo request and reply) would be an appropriate method for monitoring in that case, and Zabbix supports such simple checks. Usually, these won't work right away; to use them, we'll have to set up a separate utility, fping, which Zabbix uses for ICMP checks. It should be available for most distributions, so just install it using your distribution's package-management tools. If not, you'll have to download and compile fping manually; it's available at http://fping.sourceforge.net/.
Once fping is properly installed, the Zabbix server must know where to find it and be able to execute it. On the Zabbix server, open zabbix_server.conf and look for the FpingLocation parameter. It is commented out by default, and it defaults to /usr/sbin/fping. You can quickly find the fping binary location with this command:
$ which fping
If one of the results is /usr/sbin/fping, you don't have to change this parameter. If not, modify the parameter to point to the correct fping location and restart the Zabbix server so that it knows about the configuration change. That's not it yet. Zabbix also needs to be able to run fping with administrative privileges, so execute the following as root:
# chgrp zabbix /usr/sbin/fping # chmod 4710 /usr/sbin/fping
As the fping binary should have been owned by root before, this should be enough to allow its use by the Zabbix group as required; let's verify that.
As usual, navigate to Configuration | Hosts, click on Items next to Another host, and click on Create item. Set the following details:
- Name: ICMP ping performance
- Type: Simple check
- Key: Click on the Select button; in the list, click on the icmppingsec key, and then remove everything inside the square bracket and the brackets themselves
- Type of information: Numeric (float)
- Units: ms
- Custom multiplier (from the Preprocessing tab): Select the checkbox and enter 1000
The options in Preprocessing tab are as follows:
When all fields have been correctly set, click on the Add button at the bottom. Perform the usual round trip to Monitoring | Latest data—ICMP ping should be recording data already. If you wait for a few minutes, you can also take a look at a relatively interesting graph to notice any changes in the network performance.
Here, we set up ICMP ping measuring network latency in seconds. If you wanted to simply test host connectivity, you would have chosen the icmpping key, which would only record whether the ping was successful or not. That's a simple way to test connectivity on a large scale, as it puts a small load on the network (unless you use ridiculously small intervals). Of course, there are things to be aware of, such as doing something different to test Internet connectivity—it wouldn't be enough to test the connection to your router, firewall, or even your provider's routers. The best way would be to choose several remote targets to monitor that are known to have a very good connection and availability.
For ICMP ping items, several parameters can be specified. For example, the full icmpping key syntax is as follows:
icmpping[<target>,<packets>,<interval>,<size>,<timeout>]
By default, target is taken from the host this item is assigned to, but that can be overridden. The packets parameter enables you to specify how many packets each invocation should issue—usually, the fping default is 3. The interval parameter enables you to configure the interval between these packets—usually, the fping default is one second against the same target, specified in milliseconds. As for size, here, the default of a single packet could differ based on the fping version, architecture, and maybe other parameters. And the last one—timeout—sets individual target timeouts, with a common default being 500 milliseconds.
Note that we should not set ICMP ping items with very large timeouts or packet counts; it can lead to weird results. For example, setting the packet count to 60 and using a 60-second interval on an item will likely result in that item missing every second value.
If you set up several ICMP ping items against the same host, Zabbix invokes the fping utility only once. If multiple hosts have ICMP ping items, Zabbix will invoke fping once for all hosts that have to be pinged at the same time with the same parameters (such as packet, size, and timeout).