with check_icmp you can just check multiple ips at the same time.
just separate them by a space:
./check_icmp -h
Copyright (c) 2005 Andreas Ericsson <ae@op5.se>
Copyright (c) 2005-2008 Monitoring Plugins Development Team
<devel@monitoring-plugins.org>
Usage:
check_icmp [options] [-H] host1 host2 hostN
Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
--extra-opts=[section][@file]
Read options from an ini file. See
https://www.monitoring-plugins.org/doc/extra-opts.html
for usage and examples.
-H
specify a target
-w
warning threshold (currently 200,000ms,40%)
-c
critical threshold (currently 500,000ms,80%)
-s
specify a source IP address or device name
-n
number of packets to send (currently 5)
-i
max packet interval (currently 80,000ms)
-I
max target interval (currently 0,000ms)
-m
number of alive hosts required for success
-l
TTL on outgoing packets (currently 0)
-t
timeout value (seconds, currently 10)
-b
Number of icmp data bytes to send
Packet size will be data bytes + icmp header (currently 68 + 8)
-v
verbose
./check_icmp -H 8.8.8.8 100.100.100.100 -m 1
OK - 8.8.8.8: rta 2,219ms, lost 0% :: 100.100.100.100: rta nan, lost 100%|8.8.8.8rta=2,219ms;200,000;500,000;0; 8.8.8.8pl=0%;40;80;; 8.8.8.8rtmax=2,366ms;;;; 8.8.8.8rtmin=2,111ms;;;; 100.100.100.100rta=0,000ms;200,000;500,000;0; 100.100.100.100pl=100%;40;80;; 100.100.100.100rtmax=0,000ms;;;; 100.100.100.100rtmin=0,000ms;;;;
Depending on your needs you may remove the address attribute above, this is just to build the entire array and ping everything including the host’s address. A minimized version could look like this:
apply Service "icmp" {
check_command = "icmp"
vars.icmp_address = host.vars.ping_additional
assign where len(host.vars.ping_additional) > 0
}
ICMP config on the host
Likewise, you could also move icmp_address directly into the host object without specifying it on the service apply rule. This creates even more readable configuration.
If you don’t want to create an extra service just replace the hostalive check command in the host object. Keep in mind here that the host being down from 2 addresses may create trouble with notifications and dependencies - better have this as additional service.
The above should work, I did not test it inside config validation
I just found this thread here and I am playing with this check. Though, I’ve found a weird behaviour of this check. My check has a list of 16 hosts and the value for -m is 11, but with already one dead hosts, my check goes critical, but it should have been OK. Then I’ve tried something else: A list with only two hosts (both alive) and a value of 3 for -m, check goes OK, but should have been Critical, or?
Both checks don’t work as expected or as I understood the options, and I only use -m and -H. My version: check_icmp v2.3.1 (nagios-plugins 2.3.1)
According to the maintainer the problem was fixed with 2.3.0.
Seems like it wasn’t.
By this time I had switched to check_mping for pinging my ip addresses, so I didn’t even confirm, if it was working or not.
thanks for your reply and confirming that I wasn’t the only one with this problem. I will try compiling it, as mentioned in https://github.com/nagios-plugins/nagios-plugins/pull/487 and will report how it worked.
As a matter of fact I do need a check where I get a Critical when a given number of hosts is not alive
Greetings
and then ran the “new” check_icmp with just the -m and -H options
Tadaaa! It works now, when I have more dead hosts as given with the -m option it goes Critical
Now I have to decide on how to use it on my monitoring server, maybe copying it to a special directory (so it won’t interfere with updates) and build a new check command in Icinga is the best solution.