Icinga/Nagios to ping different machine on local network

monitoringnagiosping

I have 3 machines, all remote IPs and all of them running nsclient++ with remote and local IP addresses:

46.*.*.1/192.168.1.1
46.*.*.2/192.168.1.2
46.*.*.3/192.168.1.3

I want nagios/icinga to remotely ping other local machines to see whether VLAN is working correctly.

Is there a way to tell nagios/icinga to use machine 192.168.1.1 and to ping 192.168.1.2 and 192.168.1.3 ? check_ping is pinging only machine defined in host_name from icinga server. Icinga is on completely different ip range 92.*.*.*

Is there a way to do this to see VLAN workes fine?

Best Answer

As you are using nsclient++, I assume these are Windows hosts, and other remote execution options (e.g., push_check) are not available. However, nsclient++ has its own remote execution built-in. See details here: http://www.nsclient.org/nscp/wiki/CheckExternalScripts, for example, in the nsclient++ configuration, include

[External Scripts]
ping_remote=.\scripts\ping.bat $ARG1$

and a simple batch file scripts\ping.bat under the nsclient++ folder along these lines:

ping %1

This will exit with code 0 (Nagios "OK") if the host is reachable and code 1 (Nagios "Warning") if not. You could build a more elaborate batch script to do something a bit cleverer with the output.

Nagios's NRPE check can trigger this script. Define a command as follows:

define command {
    command_name check_ping_remote
    command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c ping_remote -a $ARG1$
}

And then fire it from the host configuration for one of your host machines with:

define service{
    host_name                       your_host_name
    service_description             Ping VPN
    check_command                   check_ping_remote!192.168.1.2
    use                             generic-service
}