Ping multiple IP addresses to see if they are up or down

An easy way to do this is by using fping. fping is a little bit easier ping utility to use then normal ping when trying to verify that a host is actually down.

By default fping returns if a host is “alive” or “unreachable”

Example:

$ fping 192.168.1.4
192.168.1.4 is alive

Or for a host that is down it returns something like the following

$ fping 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
192.168.1.5 is unreachable

You can adjust the retry rate with the -r option, default is 3 which it has multiple of the Host Unreachable lines. Changing it to 1 or 2 gets rid of those lines so it just shows that the host is unreachable.

$ fping -r 1 192.168.1.5
192.168.1.5 is unreachable

Ping multiple addresses

Fortunately pinging multiple addresses with fping is as easy as adding them to the end of the command. For example

fping -r1 192.168.1.1 192.168.1.2

will ping both the specified addresses one after the other and print the results to the terminal.

Example:

$ fping -r 192.168.1.1 192.168.1.10 192.168.1.45  
192.168.1.1 is alive
192.168.1.10 is alive
192.168.1.45 is unreachable

Optimizations for LibreNMS

Optimizations for fping.  Add to the LibreNMS config in “/opt/librenms/config.php”

$config['fping_options']['retries'] = 5;
$config['fping_options']['timeout'] = 1000;
$config['fping_options']['count'] = 4;
$config['fping_options']['millisec'] = 1000;

 

Use sysname instead of ip.  Add to the LibreNMS config in “/opt/librenms/config.php”

$config['force_ip_to_sysname'] = true;

 

Add device name to alert message.  Add to the alert templates template to show device name in alert.

%sysName\r\n