I have a special script that I wrote to send me email notifications in the event that our primary Internet connection fails. This script is a simple BASH script as follows:
Code: Select all
#!/bin/bash
/sbin/route add -host `/usr/bin/nslookup site2.mydomain.com | /bin/awk 'NF > 1' | /bin/awk '{ field = $NF}; END{print field }'` gw 192.168.1.2
/usr/bin/ssh [email protected] "sendmail -t < /root/email_wic_nagios"
/sbin/route del -host `/usr/bin/nslookup site2.mydomain.com | /bin/awk 'NF > 1' | /bin/awk '{ field = $NF}; END{print field }'` gw 192.168.1.2]In the command.cfg, I added the following command:
Code: Select all
define command{
command_name notify-internet-down
command_line /usr/bin/sudo /usr/local/nagios/libexec/internet_down.sh
}
Next I've got a special user and I've assigned their host_notification_commands and service_notification_commands to the "notify-internet-down" command.
Now when I'm testing and I take the "Internet" host down, I don't get a notification. However, if I start nagios as the nagios user without the -d (To daemonize it), the notification script works when I bring the "Internet" host down. I've tried to turn on debugging, but I'm not seeing any information on what is wrong. Any help is appreciated. Thanks!