monit-general
[Top][All Lists]
Advanced

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

Re: Q about running external scripts


From: Jan-Henrik Haukeland
Subject: Re: Q about running external scripts
Date: Wed, 21 Jan 2004 08:04:08 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, linux)

Whit Blauvelt <address@hidden> writes:

> #! /bin/sh
>
> kill `cat /var/run/$1.pid`
> ==============
>
> called through monitrc with
>
> stop program = "/bin/kill.sh pure-ftpd" 
>
> [or pure-ftpd2 - there are multiple instances and this gives it the correct
> PID to kill for the instance being tested]
>
> Now, the FAQ mentions path restrictions, but also says /bin is in the monit
> path - plus 
>
> /bin/kill `/bin/cat /var/run/$1.pid`

In a stop script you can also use the environment variable
MONIT_PROCESS_PID to get the pid to kill, such as:

if [ "x$MONIT_PROCESS_PID" != "x" ] 
then 
     kill $MONIT_PROCESS_PID
else
     error 
fi

> Now, the FAQ mentions path restrictions, but also says /bin is in the monit
> path - plus 
>
> /bin/kill `/bin/cat /var/run/$1.pid`
>
> doesn't work from monitrc either 

That wont work directly in monitrc since variable expansion is not
done there, but using `stop program = "/bin/kill.sh pure-ftpd"' should
work. To debug this you can insert "set -vx" at the top of the script
and run monit in debug mode, such as

#!/bin/sh
set -vx
...

and run monit like so: monit -Iv

This should print how the script is run from monit, to the console, so
you can investigate how variables are expanded and if an error occured. 

If you also post your monitrc file to this mailing list it will help :)

-- 
Jan-Henrik Haukeland




reply via email to

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