[Top][All Lists]

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

Re: [monit] Monitoring directory size?

From: Christopher Opena
Subject: Re: [monit] Monitoring directory size?
Date: Tue, 20 Jan 2009 22:01:50 -0800

Thanks much Martin, worked perfectly!

On Tue, Jan 20, 2009 at 1:45 PM, Martin Pala <address@hidden> wrote:
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:

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


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,
To unsubscribe:

To unsubscribe:

reply via email to

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