LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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



Reply
 
Search this Thread
Old 09-28-2010, 02:55 AM   #1
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Rep: Reputation: 75
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.
 
Old 09-28-2010, 03:02 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
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
 
Old 09-28-2010, 03:15 AM   #3
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by angel115 View Post
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.
 
Old 09-28-2010, 03:21 AM   #4
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Original Poster
Rep: Reputation: 75
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
 
Old 09-28-2010, 03:23 AM   #5
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Monit is good choice
 
Old 09-28-2010, 03:28 AM   #6
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
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
 
Old 09-28-2010, 05:43 AM   #7
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Original Poster
Rep: Reputation: 75
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
Code:
# reload cron
TESTING:
For testing I did the following:
Code:
# killall nagios
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 05:48 AM.
 
Old 09-28-2010, 05:50 AM   #8
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hello,

That's good news. Have fun with Linux.

Kind regards,

Eric
 
Old 10-01-2010, 04:09 AM   #9
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by EricTRA View Post
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.
Old 10-01-2010, 04:42 AM   #10
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Quote:
Originally Posted by quanta View Post
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
 
  


Reply

Tags
crontab, nagios, watchdog


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nagios plugin for monitoring the no. of open files for a particular process sarathveera Linux - Software 1 02-05-2010 01:43 AM
Intel's watchdog support iTCO_wdt - does this mean watchdog is not present? kushalkoolwal Linux - Hardware 3 02-06-2009 04:16 PM
Hardware watchdog in BIOS and Linux watchdog driver are different? travishein Linux - Hardware 1 12-22-2008 10:41 PM
LXer: Nagios and Oreon (Nagios web front end) installation and Configuration LXer Syndicated Linux News 0 07-18-2006 09:33 PM
process watchdog aral Red Hat 3 07-10-2006 05:54 AM


All times are GMT -5. The time now is 09:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration