monit-general
[Top][All Lists]
Advanced

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

Re: monit5.5: Problem with process restart


From: Martin Pala
Subject: Re: monit5.5: Problem with process restart
Date: Thu, 6 Dec 2012 15:04:13 +0100

Monit executes the program using execv() ... it doesn't interpret it as script. You need to specify the interpreter at the script start, for example:

--8<--
#!/bin/bash
...
--8<--

Regards,
Martin


On Dec 6, 2012, at 2:59 PM, shiva rkreddy <address@hidden> wrote:

Thanks Martin.
With verbose mode, I was able to see that monit was complaining about missing "stop program" in the config file.
Got around the error and added a new script to handle start/stop of the process. Still, its failing to restart.

Here is corresponding log entry:
===
[CST Dec  6 08:39:41] debug    : 'whileTest' Error testing process id [8075] -- No such process
[CST Dec  6 08:39:41] error    : 'whileTest' process is not running
[CST Dec  6 08:39:41] info     : 'whileTest' trying to restart
[CST Dec  6 08:39:41] debug    : 'whileTest' Error testing process id [8075] -- No such process
[CST Dec  6 08:39:41] debug    : 'whileTest' Error testing process id [8075] -- No such process
[CST Dec  6 08:39:41] info     : 'whileTest' start: /tmp/monit.sh
[CST Dec  6 08:39:41] debug    : 'whileTest' Error testing process id [8075] -- No such process
[CST Dec  6 08:39:42] debug    : 'whileTest' Error testing process id [8075] -- No such process
[CST Dec  6 08:40:18] error    : 'whileTest' failed to start

===

Script:

RETVAL=0
modulename="/tmp/whileTest"
start() {

        cnt=$(ps -T | grep -c $modulename 2>/dev/null)
        if [ $cnt -le 1 ] ;  then
                $modulename &
        else
                echo "$modulename already running"
                echo
        fi
        return $RETVAL
}

stop() {
        pkill -f "$modulename "
}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
esac
exit $?


reply via email to

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