You can execute a script if you specify a plugin command on the remote server.
In the example below the plugin command is get_disk
:
command[get_disk]=csript.exe c:\nagios\checks\check_disks_percentage_spave_used.vbs
I would however like NRPE on the remote server to execute a script on the client server, without a plugin command.
On the remote server something like this:
check_nrpe -H 196.35.132.9 -t 60 -c 'csript.exe c:\\nagios\\checks\\check_disks_percentage_space_used.vbs'
You can follow following steps to run a command from nagios to monitor a remote machine
put your script/plugin/executable file in slave machine @ /usr/local/nagios/libexec location.
e.g. - /usr/local/nagios/libexec/test.sh
and give it executable permission.
chmod +x test.sh
vi /usr/local/nagios/etc/nrpe.cfg
add following line
command[testScript]=/usr/local/nagios/libexec/test.sh
telling nrpe to run test.sh when it receives testScript command
8. restart nrpe
9. goto master machine
10. edit commands.cfg
vi /usr/local/nagios/etc/objects/commands.cfg
and add following linedefine command{
command_name check_nrpe
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
by adding this, now master machine is aware what is check_nrpe command.
add a service
define service{
use generic-service
host_name web-node01
service_description count number of cmd in remote mc
check_command check_nrpe!testScript
}
now nagios know that it has to call testScript command in slave machine,
and in slave machine we have defined when received testScript command run 'test.sh'
from thi s'/usr/local/nagios/libexec' location (point no. 7)
now before trying it from nagios you can directly call the nrpe command to check is everything is working fine by following command
/usr/local/nagios/libexec/check_nrpe -H slave_IP_Address -c testScript
P.S. this is exactly same command that nagios will run behind the scene