Great, it worked after adding the #!/bin/bash. I've another question on whether monit can restart a process based on number of threads that are running? For example: A process has 10 threads to start with and then 7 of the threads have crashed. It needs 5 threads to be running to be considered healthy. If thread count is less than 5, can monit restart the whole process?
Thanks On Thu, Dec 6, 2012 at 8:04 AM, Martin Pala <[email protected]> wrote: > 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 <[email protected]> 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 $? > > >
-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general
