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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-01-2009, 05:44 PM
|
#1
|
Member
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84
Rep:
|
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?
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?
|
|
|
06-01-2009, 07:43 PM
|
#2
|
Moderator
Registered: May 2001
Posts: 29,415
|
Monit will first issue the stop then the start command.
|
|
|
06-01-2009, 08:08 PM
|
#3
|
Member
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84
Original Poster
Rep:
|
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
|
|
|
|
06-02-2009, 06:52 AM
|
#4
|
Moderator
Registered: May 2001
Posts: 29,415
|
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.
|
|
|
06-02-2009, 11:33 AM
|
#5
|
Member
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84
Original Poster
Rep:
|
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
|
|
|
|
06-02-2009, 11:53 AM
|
#6
|
Moderator
Registered: May 2001
Posts: 29,415
|
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.
|
|
|
06-02-2009, 07:45 PM
|
#7
|
Member
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84
Original Poster
Rep:
|
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.
|
|
|
06-03-2009, 02:41 AM
|
#8
|
Moderator
Registered: May 2001
Posts: 29,415
|
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.
|
|
|
06-04-2009, 10:55 AM
|
#9
|
Member
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84
Original Poster
Rep:
|
Ah, okay, thanks for the help!
|
|
|
All times are GMT -5. The time now is 04:09 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
|
|