LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Monit parameters (https://www.linuxquestions.org/questions/linux-software-2/monit-parameters-729976/)

linuxfia 06-01-2009 05:44 PM

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?

unSpawn 06-01-2009 07:43 PM

Monit will first issue the stop then the start command.

linuxfia 06-01-2009 08:08 PM

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

unSpawn 06-02-2009 06:52 AM

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.

linuxfia 06-02-2009 11:33 AM

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

unSpawn 06-02-2009 11:53 AM

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.

linuxfia 06-02-2009 07:45 PM

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.

unSpawn 06-03-2009 02:41 AM

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.

linuxfia 06-04-2009 10:55 AM

Ah, okay, thanks for the help!


All times are GMT -5. The time now is 02:39 AM.