Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
09-28-2010, 01:55 AM
#1
Member
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 450
Rep:
Looking for watchdog to take care of nagios process
Hello There,
I'm looking for a watchdog program that would take care of nagios process and restart it if it hangs or quit unexpectedly.
I was thinking using CRONTAB to do so.
Is it a good idea, or is there a better solution?
Does anyone already done this?
Best regards,
Angel.
09-28-2010, 02:02 AM
#2
Guru
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Hi,
This one was posted on the Nagios Users list a while ago but still does the trick.
Code:
#!/bin/bash
plugindir="/usr/local/nagios/libexec"
cmdstart='/sbin/service nagios start'
#Check nagios with check_nagios plugin
$plugindir/check_nagios -e 5 -F /usr/local/nagios/var/nagios.log
-C /usr/local/nagios/bin/nagios
if [ "${?}" != 0 ] ; then
echo "CRITICAL:Nagios not found running..."
$cmdstart
else
echo "OK:Nagios runnning..."
fi
exit
Change where needed and put it in a crontab with a user who's permitted to start the Nagios process.
Kind regards,
Eric
09-28-2010, 02:15 AM
#3
Member
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 723
Rep:
Quote:
Originally Posted by
angel115
I'm looking for a watchdog program that would take care of nagios process and restart it if it hangs or quit unexpectedly.
monit/mmonit is a famous program in this field. Another way, you can use check_nagios plugin.
09-28-2010, 02:21 AM
#4
Member
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 450
Original Poster
Rep:
Thanks alot to you both.
I think I'll use check_nagios for now, but I'll keep monit in my pocket for later
Angel
09-28-2010, 02:23 AM
#5
Senior Member
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,094
Rep:
Monit is good choice
09-28-2010, 02:28 AM
#6
Guru
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Hi,
You're welcome. If you've used them both for a while it would be appreciated if you could post your experiences here at LQ.
Kind regards,
Eric
09-28-2010, 04:43 AM
#7
Member
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 450
Original Poster
Rep:
Hi EricTRA,
After some test it's working find using your script:
1. I create a new file with your script inside in
/usr/local/nagios/bin/nagios_watchdog
2. Change the right and owner to make it executable to
750 and
nagios:nagios respectively.
3. I add a new line in my
/etc/crontab file (This will run the script every 2 minutes)
Code:
*/2 * * * * nagios /usr/local/nagios/bin/nagios_watchdog
3. I reload my crontab
TESTING:
For testing I did the following:
Then I try to access my nagios web page ==>> result, no access
new attempt after 2 minutes ==>> result, Nagios is back on track
Last edited by angel115; 09-28-2010 at 04:48 AM .
09-28-2010, 04:50 AM
#8
Guru
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Hello,
That's good news. Have fun with Linux.
Kind regards,
Eric
10-01-2010, 03:09 AM
#9
Member
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 723
Rep:
Quote:
Originally Posted by
EricTRA
Code:
#!/bin/bash
plugindir="/usr/local/nagios/libexec"
cmdstart='/sbin/service nagios start'
#Check nagios with check_nagios plugin
$plugindir/check_nagios -e 5 -F /usr/local/nagios/var/nagios.log
-C /usr/local/nagios/bin/nagios
if [ "${?}" != 0 ] ; then
echo "CRITICAL:Nagios not found running..."
$cmdstart
else
echo "OK:Nagios runnning..."
fi
exit
More exactly, I suggest you check with:
Code:
./check_nagios -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios | awk '{ print $2 }'
Because when the system time is wrong, although the nagios is still running, check_nagios plugin return the following warning and exit status=1:
Code:
# ./check_nagios -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios
NAGIOS WARNING: 1 process, status log updated 1221 seconds ago
# echo $?
1
1 members found this post helpful.
10-01-2010, 03:42 AM
#10
Guru
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Quote:
Originally Posted by
quanta
More exactly, I suggest you check with:
Code:
./check_nagios -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios | awk '{ print $2 }'
Because when the system time is wrong, although the nagios is still running, check_nagios plugin return the following warning and exit status=1:
Code:
# ./check_nagios -e 5 -F /usr/local/nagios/var/nagios.log -C /usr/local/nagios/bin/nagios
NAGIOS WARNING: 1 process, status log updated 1221 seconds ago
# echo $?
1
Hi,
That's why NTP has been invented, to avoid wrong system times
Since correct time is crucial when monitoring I always set up my servers with NTP to synchronize time. Of course if there's no possibility to sync time, or the admin is not aware of a 'wrong' system time then your solution is more adequate.
Kind regards,
Eric
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 01:06 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News