monit-general
[Top][All Lists]
Advanced

[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:1.8.0.9) 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 - http://www.tildeslash.com/monit/doc/next.php#33). 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
       directory:
       --8<--
       #!/bin/bash
       if [ `ls -1 /tmp |wc -l` -lt 100 ]
       then
         touch /var/tmp/monit_flag_tmp
       fi
       --8<--

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

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

       Done :)

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

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:
       --8<--
       #!/usr/bin/bash
       /usr/sbin/metastat > /var/tmp/monit_svm
       --8<--

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


Thanks,
Martin

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: http://lists.nongnu.org/archive/html/monit-general/2007-01/msg00008.html

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
suggestions.

Thanks again for this useful program,
Matt





reply via email to

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