On 8/14/07, Martin Pala <[EMAIL PROTECTED]> wrote:
> Currently just global alert ('set alert ...') is implemented this way.Which means I have to write exec handlers for each monitored process separately. I want to execute a script whenever process starts, stops, restarts or encounters some error. The first thing that comes on my mind is to check the pid file if exists or it's changed. To execute the script when process restart I will add in the "check process" block: check pidfile with path /path/to/the/pidfile if changed pid then exec "/path/to/script" To execute the script when process is stopped: #check if the pid file does not exist for 2 cycles and execute script check file pidfile.pid with path /path/to/pid if failed nonexist for 2 cycles then exec "/path/to/script" To execute the script when process is started: # check if the timestamp is less or equal to the monit cycle time # if the process was started between two cycles check file pidfile.pid with path /path/to/pid if timestamp <= <MONIT_CYCLE_TIME> then exec "/path/to/script" The problem with this approach (timestamp check) is that the timestamp will change on process restart (pid change) as well. How can I check the state of the process for processes that don't delete their pid file? Is there another way to check the state of the process except checking its pid file? How can I create an error handler. Is counting restart atempts good (if the process can't be restarted x times than an error occured)? For example: check file pidfile.pid with path /path/to/pid if 3 restarts in 3 cycles then exec "/path/to/script" BR, Jovan -- To unsubscribe: http://lists.nongnu.org/mailman/listinfo/monit-general
