[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [monit] Monitoring script output
From: |
Martin Pala |
Subject: |
Re: [monit] Monitoring script output |
Date: |
Wed, 17 Mar 2010 21:23:51 +0100 |
Native support for delegating check to script is planned, in the mean time you
can use following workarounds:
1.) 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<--
On Mar 17, 2010, at 4:08 PM, Mark Olliver wrote:
> Is is possible to monitor the result of a script for example once every
> 5 mins.
>
> I would like to reduce our reliance on nagios for internal monitoring
> but we have a few checks like an expect script which logs into our
> servers and runs a few checks. Ideally i would like monit to monitor
> these as well.
>
> Mark Olliver BSc (Hons) MBCS CITP
> Thermeon (System Admin)
> Russ Hill Farm, Russ Hill, Charlwood, RH6 0EL, UK
> +44 1293 864 300
>
>
>
> --
> To unsubscribe:
> http://lists.nongnu.org/mailman/listinfo/monit-general