monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [monit] exec command not always work


From: Martin Pala
Subject: Re: [monit] exec command not always work
Date: Tue, 1 Sep 2009 21:32:04 +0200

Hi,

you can use monit -v option to see details of the actions and why it is failing. 

I guess that the problem could be the restart line preceding the exec ... most probably it gets executed first, so the shutdown line is not performed, since restart action stops->start the service. The solution will be to change the order, so the exec line is evaluated first.

Martin


On Sep 1, 2009, at 3:35 PM, Aldous Leung wrote:

Hi,
 
I would like to reboot the server when some service failed 5 times. I used the "exec" command to do this. But, the command works only "check system". Would anyone know what is wrong, please? Thank you very much.
 
The following statement is working and it will reboot my OpenSuse:
(sysreboot.sh will call "shutdown -r now") 
--------------------------------
check system myOpenSuse
     if memory usage > 80% for 5 times within 5 cycles then alert
     if cpu usage (user) > 70% for 5 times within 5 cycles then alert
     if cpu usage (system) > 90% for 15 times within 20 cycles then exec "/etc/sysreboot.sh"
--------------------------------
 
But, the following two statements will not reboot my system. I got "event: Execution failed"
-------------------------------
check process Postfix with pidfile /var/spool/postfix/pid/master.pid
    start program = "/etc/init.d/postfix start"
    stop program = "/etc/init.d/postfix stop"
    if failed host localhost port 25 protocol smtp then restart
    if failed host localhost port 25 protocol smtp for 5 times within 10 cycles then
       exec "/etc/sysreboot.sh"
 
  check process MySQL with pidfile /var/lib/mysql/mysqld.pid
    start program = "/etc/init.d/mysql start"
    stop program = "/etc/init.d/mysql stop"
    if failed host localhost port 3306 protocol mysql then restart
    if failed host localhost port 3306 protocol mysql for 5 times within 10 cycles then
       exec "/bin/bash -c '/sbin/shutdown -r now'"
-------------------------------
 
Aldous
--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general


reply via email to

[Prev in Thread] Current Thread [Next in Thread]