Below is the example of script to check the public IP and give output to nagios
-------------------------------------------------------------------------------
#!/bin/sh IP=`curl -s ifconfig.me` LEASE=202.147.38.202 if [ $IP == $LEASE ]; then echo $IP exit 0 else echo $IP exit 2 fi
-------------------------------------------------------------------------------
According to nagios, it use exit code to determine the output to give what kind of response.
so below is the exit code
State OK = 0 State Warning = 1 State Critical = 2 State unknown = 3 State Dependent = 4 ---------------------------------------------------------- Now we will add this script to the client side and define the command to nagios We will need to edit nrpe.cfg file and add this into itcommand[check_lease]=/etc/nagios/check_lease this command will allow nagios server to call this command ---------------------------------------------------------- Then we need to define this command at client side for the path of the script to execute at commands.cfgdefine command{ command_name check_lease command_line /bin/bash /etc/nagios/check_lease } This will state check_lease is refer to which shell script ---------------------------------------------------------- The last part is add the check command to the server sidedefine service{ use local-service host_name my-proxy service_description lease check_command check_nrpe!check_lease }