monit-general
[Top][All Lists]
Advanced

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

Re: [monit] monitor process in memory


From: David Touzeau
Subject: Re: [monit] monitor process in memory
Date: Mon, 12 Apr 2010 18:17:44 +0200
User-agent: Thunderbird 2.0.0.24 (X11/20100411)



M/Monit support wrote:
Hello,

currently monit requires pid file - we will add support for monitoring 
processes without pid file in the future.

The workaround is simple - you can prepare wrapper for your program startup 
which will write PID of the program to the pid file. Excerpt from 
(http://mmonit.com/wiki/Monit/FAQ#pidfile:

--8<--
Q: I have a program that does not create its own pid file. Since monit requires 
all programs to have a pid file, what do I do?
A: Create a wrapper script and have the script create a pid file before it 
starts the program. Below you can find an example script for starting an 
imaginary program (a Java program in this case). Assuming that the script is 
saved in a file called /bin/xyz, you can call this script from monit by using 
the following in monitrc:

 check process xyz with pidfile /var/run/xyz.pid
       start = "/bin/xyz start"
       stop = "/bin/xyz stop"

The wrapper script:

 #!/bin/bash
 export JAVA_HOME=/usr/local/java/
 CLASSPATH=ajarfile.jar:.

 case $1 in
    start)

       echo $$ > /var/run/xyz.pid;
exec 2>&1 java -cp ${CLASSPATH} org.something.with.main 1>/tmp/xyz.out ;; stop) kill `cat /var/run/xyz.pid` ;; *) echo "usage: xyz {start|stop}" ;;
 esac
 exit 0
--8<--

... the "echo $$" writes PID to file and exec starts the program and inherits the 
PID which was written to the pid file. If the program forks/demonize itself, the PID file 
can be different then what was written to the file - in this case you can use instead 'pgrep 
myprogram > /var/run/xyz.pid' or if pgrep is not available, use some equivalent (ps -ef | 
grep ...).

Regards,
M/Monit support


On Apr 11, 2010, at 11:29 AM, David Touzeau wrote:

Dear

I use monit but i need to monitor a process daemon that did not create Pid file.

Is there any way to specify monit verify if a process (given by it's full path 
or it's command line) is on memory or not ?

best regards


--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general



--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general


I prefer waiting new features. Your solution is about when you can drive the lauching process. In my case, i cannot script the startup script because it depends with other daemon.





reply via email to

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