Zabbix 4 Network Monitoring
上QQ阅读APP看书,第一时间看更新

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/.

fping should come with your distribution if not make sure it is installed on your system. If you make use of SELinux, then it might be that SELinux prevents Zabbix from using fping as fping needs to be run as root. In that case, the solution is to create a proper SELinux rule for this.

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  
Permissions are usually already correct in Fedora/RHEL-based distributions. If you're using distribution packages, don't execute the previous commands; they might even disallow access for the Zabbix server, as it might be running under a different group.

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 dataICMP 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 connectivityit 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 issueusually, the fping default is 3. The interval parameter enables you to configure the interval between these packetsusually, 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 onetimeoutsets individual target timeouts, with a common default being 500 milliseconds.

These defaults are not Zabbix defaults, if not specified, fping defaults are used.

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).

fping needs the SUID bit set to work properly. This is because fping needs root permissions to work but we run our Zabbix setup as a regular Zabbix user. In most cases, this will be set out of the box by your distribution but, just in case, check it if you run into issues. The proper settings can be verified like this:
If you don't use IPV4 but IPV6, then you need to configure fping for IPV6 in the Zabbix server configuration; that also means that you need to install fping6 next to fping. The usual location is  /usr/sbin/fping6.