|
From: | Christopher Opena |
Subject: | Re: [monit] Monitoring directory size? |
Date: | Tue, 20 Jan 2009 22:01:50 -0800 |
Hi, the mentioned workaround should work and it was used in the past by several users.
We can implement native size test for directory as well - it could be interesting feature for some next monit version. We also plan to add external scripts monitoring support: http://mmonit.com/monit/next/
Similar workaround (FAQ.txt snip):
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<--
Martin
On Jan 20, 2009, at 1:24 PM, Christopher Opena wrote:
--Hello all, new to the list and pretty new to monit. I'm trying to do some alerting on directory size (as opposed to file size) and I see that 'size' is not a valid check under directory. Well I tried it anyway under monitrc and sure enough I got a "Error: syntax error 'size'". I've been thinking of some creative ways to get around this, including setting up a cron job to create an output file of a 'du -hs {directory_path}' and then having Monit do a regex check on the file contents.
Anyone out there doing something similar and have a cleaner way they've found of doing this?
Thanks in advance,
-Chris
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general
[Prev in Thread] | Current Thread | [Next in Thread] |