monit-general
[Top][All Lists]
Advanced

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

Re: Basic q's abt monit 4.5.1


From: anuj agrawal
Subject: Re: Basic q's abt monit 4.5.1
Date: Mon, 19 Sep 2005 05:58:16 +0100 (BST)

Hi Martin,

Loads and loads of thanks for the reply...

Another basic doubt....

MONIT wants the pid file(hence the pid of the process)
of the process which it wants to restart.Now, the pid
of the process is only generated when the process is
up and running...hence if the process is already up
then how does MONIT take the credit of starting the
process???

Anuj
--- Martin Pala <address@hidden> wrote:

> One possible way to create the pidfile in such case
> is described in 
> monit FAQ:
> 
> 
> 3. 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 will
> 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 /tmp/xyz.pid
>          start = "/bin/xyz start"
>          stop = "/bin/xyz stop"
> 
> 
>            --8<--- (cut here)
> 
>            #!/bin/bash
>            export JAVA_HOME=/usr/local/java/
>            export DISPLAY=localhost:0.0
>            CLASSPATH=ajarfile.jar:.
> 
>            case $1 in
>             start)
>             echo $$ > /tmp/xyz.pid;
>             exec 2>&1 java -cp ${CLASSPATH}
> org.something.with.main \
>             1>/tmp/xyz.out
>             ;;
>            stop)
>             kill `cat /tmp/xyz.pid` ;;
>            *)
>             echo "usage: xyz {start|stop}" ;;
>            esac
> 
>            --8<---- (cut here)
> 
> 
> Another simple method could be to append something
> like:
> 
>   'pgrep myprocess > /var/run/myprocess.pid'
> 
> to the startup script after the process was actualy
> started.
> 
> 
> anuj agrawal wrote:
> > Hi Christian,
> >  
> > Thanks for the reply....
> >  
> > The problem with my server process is that it
> doesnt create any pid file 
> > on start up....i had manually created a pid file
> for the server and 
> > copied the pid of the process in it....then only
> was monit able to 
> > monitor it (it showed the status as running).
> >  
> > Thats why i asked that how would monit come to
> know the pid of the 
> > server when restarting it.
> >  
> > Is there ne way to make a process create a pid
> file after startup???
> >  
> > If not then given the situation of how i create
> the pid file..what 
> > should i do to make monit restart my process.
> >  
> > Anuj
> > 
> > */Christian Kowarzik <address@hidden>/* wrote:
> > 
> >     Hi Anuj,
> > 
> >     anuj agrawal wrote:
> >      > Hello all,
> >      >
> >      > Well for my intro i am a newbie in the
> world of MONIT
> >      > and hence facing some difficulties using
> it.
> >      >
> >      > I am using monit 4.5.1 to monitor a certain
> server
> >      > which is written in java. When the server
> is up there
> >      > is no pid file generated by it hence i
> wrote my own
> >      > pid file and i wrote the pid of the server
> process in
> >      > it.
> >      >
> >      > Once this was done i made an emtry in the
> monitrc file
> >      > placed in /etc as:
> >      >
> >      > check process server with pidfile
> /var/run/server.pid
> >      > start = "............"
> >      > stop = "............"
> >      >
> >      > after doing this i started the monit web
> interface in
> >      > which it was easily recognising and
> monitoring the
> >      > process "server".It showed the status as
> running and
> >      > all the required information was correctly
> displayed.
> >      >
> >      > Now,i pressed the "stop" button and hence
> the process
> >      > was successfully stopped.
> >      >
> >      > Now comes the problem , when i try to start
> the server
> >      > through monit it doesnt and shows
> "execution failed".
> >      >
> >      > Questions i have are:
> >      >
> >      > 1) When starting a service how does monit
> come to know
> >      > the pid of the process???
> >     by looking in the pid file you specified in
> the monit.conf like in
> >     'check process server with pidfile
> /var/run/server.pid'
> >      >
> >      > 2) Does monit itself places the pid of the
> started
> >      > process in the pid file??(i.e. updates the
> pidfile)
> >     no, the proccess you started itself is
> responsible for placing its pid
> >     in the pidfile - or your startup script if the
> proccess itself is not
> >     able to do so
> >      >
> >      > Eagerly awaiting replies.
> >      >
> >      > Thanks,
> >      > Anuj
> > 
> >     christian
> >      >
> >      >
> >      >
> >      >
> >      >
> >      >
> >      >
>
__________________________________________________________
> >      > Yahoo! India Matrimony: Find your partner
> online. Go to
> >     http://yahoo.shaadi.com
> >      >
> >      >
> >      > --
> >      > To unsubscribe:
> >      >
>
http://lists.nongnu.org/mailman/listinfo/monit-general
> >     begin:vcard
> >     fn:Christian Kowarzik
> >     n:Kowarzik;Christian
> >     org:PROFESSIONAL IT-SERVICE
> >    
>
adr;quoted-printable;quoted-printable:;;Kaiserstra=C3=9Fe
> >     28b;D=C3=BCsseldorf;NRW;40479;Deutschland
> >     email;internet:address@hidden
> >     tel;work:0211 - 545 11 37
> >     tel;fax:0211 - 152 00 50
> >     tel;cell:0179 - 226 28 90
> >     x-mozilla-html:FALSE
> >     version:2.1
> >     end:vcard
> > 
> >     --
> >     To unsubscribe:
> >    
>
http://lists.nongnu.org/mailman/listinfo/monit-general
> > 
> >
>
------------------------------------------------------------------------
> > Yahoo! India Matrimony <http://yahoo.shaadi.com>:
> Find your partner now.
> 
=== message truncated ===



                
__________________________________________________________ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com




reply via email to

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