[Top][All Lists]

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

Re: External scripts (was Re: Quota Support)

From: Martin Pala
Subject: Re: External scripts (was Re: Quota Support)
Date: Sun, 11 Feb 2007 22:45:35 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20061219 Iceape/1.0.7 (Debian-1.0.7-2)

Good suggestion, hint added to FAQ. It is also possible to use file content testing (described bellow as well):

13. Q: Is here any support for external testing scripts available?

A: We plan to add the support for external scripts in the future (see our
       TODO list - Until
       native support will be available, here are some workarounds:

       1.) nice workaround contributed by Pavel Urban is based on timestamp
monitoring of file, which is updated by external script, running from cron. When everything is OK, the script will update (touch) the file.
       When the state is false, the script won't update the timestamp and
       monit will perform the related action.

       For example script for monitoring the count of files inside /tmp
       if [ `ls -1 /tmp |wc -l` -lt 100 ]
         touch /var/tmp/monit_flag_tmp

       run this script via cron (for example, every 20 minutes):
        20 * * * * /root/test_tmp_files > /dev/null 2>&1

and do timestamp check on /var/tmp/monit_flag_tmp (or any file you decide)
       in monit control file:
        check file monit_flag_tmp with path /var/tmp/monit_flag_tmp
          if timestamp > 25 minutes then alert

       Done :)

       Another Example script: for monitoring the Solaris Volume Manager
       /usr/sbin/metastat | /usr/xpg4/bin/grep -q maintenance
       if [ $? -ne 0 ]; then
         touch /var/tmp/monit_flag_svm

2.) alternatively you can use the monit's file content testing to watch
       logfiles or status files created similar way as described above.

       Example script:
       /usr/sbin/metastat > /var/tmp/monit_svm

       and example monit syntax:
       check file svm with path /var/tmp/monit_svm
         if match "maintenance" then alert


Matt Corks wrote:
On Thu, Feb 08, 2007 at 01:16:51AM +0100, Martin Pala wrote:
In general, it is possible to use external script for monitoring
various services which are not supported by monit currently. There is
nice trick developed by Pavel Urban, see for example:

That's a very useful trick.  My one complaint with monit now is that
it's not possible to call an external script from monit and check the
return value, although I realize this is already described as a high
priority on the list of planned features for the future.  For example,
I'm currently using monit to watch a server pool running a custom
routing daemon running on top of postgis, and would like to be able to
use monit to watch several parts of this complex setup.  I've resorted
to writing a series of CGI test scripts and doing something like this:

    if failed url http://user:address@hidden/script.php and content == "OK"
        timeout 30 seconds then alert

This is good enough for me for now, but until that planned feature is
added, may I suggest adding that link to Pavel's message somewhere
under the documentation section of the monit webpages?  I'm sure I
wasn't the only one who's needed to do this and went looking there for

Thanks again for this useful program,

reply via email to

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