Nagios hearbeat notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
parsons256
Posts: 2
Joined: Wed Dec 12, 2012 10:22 am

Nagios hearbeat notifications

Post 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
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Nagios hearbeat notifications

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
parsons256
Posts: 2
Joined: Wed Dec 12, 2012 10:22 am

Re: Nagios hearbeat notifications

Post 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!!
ScareCrow57
Posts: 4
Joined: Tue Apr 24, 2012 6:45 am

Re: Nagios hearbeat notifications

Post 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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Nagios hearbeat notifications

Post 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:parsons256@real-domain.com
from:nagiosserver@real-domain.com
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.)
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked