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 06-01-2009, 05:44 PM   #1
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Rep: Reputation: 15
Monit parameters


Hello,
I have a question about configuring monit.

Let's say I have the following lines for monitoring the sshd.
Quote:
check process sshd with pidfile /var/run/sshd.pid
start program “/etc/init.d/ssh start”
stop program “/etc/init.d/ssh stop”
if failed host 127.0.0.1 port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

What I want to do is if sshd stopped running for some reason, I want it to start it as I want sshd to be running at all times.
So does the line
Quote:
if failed port 22 protocol ssh then restart
actually run the command to restart it as below when it cannot ping 22?
Quote:
/etc/init.d/ssh restart
Or does it
Quote:
stop program “/etc/init.d/ssh stop”
then
Quote:
start program “/etc/init.d/ssh start”
to accomplish the line
Quote:
if failed port 22 protocol ssh then restart
?

If the stop and start lines aren't associated with the restart line then when do they kick in?
 
Old 06-01-2009, 07:43 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Monit will first issue the stop then the start command.
 
Old 06-01-2009, 08:08 PM   #3
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Thanks!
Is this line necessary for the restart to work or does it work without it?
Quote:
if failed host 127.0.0.1 port 22 protocol ssh then restart
 
Old 06-02-2009, 06:52 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Monit doesn't have any concept of ESP or otherwise guessing what a user wants. Until then an "if [TEST] then [DOSOMETHING]" line is necessary, yes.
 
Old 06-02-2009, 11:33 AM   #5
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Then how would I add one for ntp? It uses UDP port 123 not tcp.
I've added the lines below and stopped the ntp service and it seems to work as it started ntp service.

Quote:
check process ntpd with pidfile /var/run/ntpd.pid
group ntp
start program = "/etc/init.d/ntp start"
stop program = "/etc/init.d/ntp stop"
if 5 restarts within 5 cycles then timeout
 
Old 06-02-2009, 11:53 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Sure your PID test would work OK (but group doesn't do much here unless you have other services in the "ntp" group), and Monit understands UDP and NTP (NTP3) so you should have no trouble following the manual, see "connection testing" for examples.
 
Old 06-02-2009, 07:45 PM   #7
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Ah, okay...
Thanks for all the help.
Is there a way to monitor a service that doesn't create a pid file?
There's this application that runs that doesn't create the pid file but would like to monitor it.
 
Old 06-03-2009, 02:41 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
For checking the PID there are workarounds like using a wrapper script that saves the PID on application start but basically it depends on if the application has any features Monit can check. I hope you understand that without providing more details it's hard to tell.
 
Old 06-04-2009, 10:55 AM   #9
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Ah, okay, thanks for the help!
 
  


Reply


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
Monit and Mysql bichonfrise74 Linux - Newbie 2 05-04-2009 11:47 AM
little help getting monit working please steve51184 Linux - Software 1 02-24-2009 04:56 PM
Disappointed from Monit, need advice lusine Linux - Newbie 1 02-07-2009 06:09 AM
Problem with Setting up monit helptonewbie Linux - Software 2 07-29-2007 04:24 PM
monitoring daemons, filesystems and more (Monit v4.0B) markus1982 Linux - Software 2 09-14-2003 08:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:09 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
Open Source Consulting | Domain Registration