Page 1 of 1
Nagios hearbeat notifications
Posted: Wed Dec 12, 2012 10:29 am
by parsons256
Hi , I am looking for a way to get Nagios to send a heartbeat notification if the localhost is up and running, and I would like to schedule this to happen overnight.
I have done some googleing and have been unable to find a solution. I have tried using the check_host_alive command with no success.
If anyone could offer some help , or point me in the right direction I would really appreciate it
Thank you
Chris Parsons
Re: Nagios hearbeat notifications
Posted: Wed Dec 12, 2012 11:28 am
by sreinhardt
To clarify, you are looking for the Nagios server to check if it is up and running, a physical host that nagios is running on, or is there a specific metric you are looking for? The check-host-alive certainly should do the trick for local or remote hosts provided the nagios host can communicate with that server. You might also post the configuration that you are using, and I can take a look.
Re: Nagios hearbeat notifications
Posted: Wed Dec 12, 2012 1:43 pm
by parsons256
Thanks for the reply!
Yes your right, I am looking for a way to get Nagios to send me notifications telling me it is still alive.
Under localhost.cfg I defined the following service
Define service {
use local-service
hostgroup_name localhost
check_command check-host-alive
normal_check_interval 5
}
Here is the Check-host-alive command as defined in commands.cfg
Define command {
command_name check-host-alive
command_line $USER1$/check_ping –H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
}
I'm assuming the problem is with nagios only sending updates on state changes, and not when a successful ping check is performed
Thank you again for your help!!
Re: Nagios hearbeat notifications
Posted: Thu Dec 13, 2012 10:10 am
by ScareCrow57
I did this with a perl script that runs the command "service nagios status" and then sends an email. The script runs in a cron job every 4 hours.
Re: Nagios hearbeat notifications
Posted: Thu Dec 13, 2012 10:10 am
by sreinhardt
If you wish to receive an alert letting you know that nagios is alive, and not that it or another host has gone down, using chec-host-alive check. You could create a separate command that is virtually the same but changes warning or critical depending on what you would like to receive.
Code: Select all
Define command {
command_name check-nagios-warning
command_line $USER1$/check_ping –H $HOSTADDRESS$ -w 0,0% -c 5,5% -p 1
}
Define command {
command_name check-nagios-critical
command_line $USER1$/check_ping –H $HOSTADDRESS$ -w 0,0% -c 0,0% -p 1
}
Now this will end up being counter-intuitive as it will say that its down, but really that is just an easy way to send yourself an email. It will continue to send for each host notification interval that is set, so you would want to be sure it is reasonably far apart. Alternatively, you could define another command that sends an email to you directly and reports ok if it sends. This way the status is always OK, but you still receive a message.
Code: Select all
Define command {
command_name check-nagios-sendmail
command_line /path/to/sendmail -t file-with-mail-message
}
File-with-mail-message:
to:[email protected]
from:[email protected]
subject: Everything is Working!
Everything is working great here! If you don't hear from me in X minutes something has happened.
(Note the extra lines to properly format the message.)