[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Monitoring File not executing script....
From: |
Jan-Henrik Haukeland |
Subject: |
Re: Monitoring File not executing script.... |
Date: |
Sat, 10 Mar 2012 15:51:32 +0100 |
I've tested this and Monit does as expected and outputs to /tmp/dan.out. If it
does not work for you, here are a couple of things to check;
1) First, make sure the script is executable by doing 'chmod 755
/usr/foo/bin/dan'. I would also change the start of the script to #!/bin/bash
That is, invoke the interpreter directly. Monit uses the system call, execv(3)
to execute the script and execv expect the first line in a script to be the
interpreter.
2) You can also always debug why the script failed to start by outputting
errors to a file. To do this, use bash to exec the script and to report any
errors. In your case it will be;
if changed timestamp then exec "/bin/bash -c '/usr/foo/bin/dan &>/tmp/dan.err'"
This will output any errors to /tmp/dan.err which you can then investigate. As
mentioned above, you will probably find the following error there; /bin/bash:
/usr/foo/bin/dan: Permission denied
3) Finally, you can test that Monit identify that the file timestamp was
changed and that Monit does what it should by running Monit in debug mode. To
do that, start Monit using 'monit -Iv' Monit will then print debug and trace
info to the console and you should see something like:
'net_started' timestamp was not changed for /dev/shm/net_started
'net_started' file exists check succeeded
'net_started' is a regular file
'net_started' timestamp was changed for /dev/shm/net_started
'net_started' exec: /bin/bash
===
If you do not want an alert on timestamp testing you can filter out alerts for
timestamp globally using
set alert address@hidden not on {timestamp}
or use noalert locally in the check, as in
check file net_started with path /dev/shm/net_started
noalert address@hidden
if changed timestamp then exec "/usr/foo/bin/dan"
Hope this helps!