help-cfengine
[Top][All Lists]
Advanced

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

Number of files in a directory?


From: nathan r. hruby
Subject: Number of files in a directory?
Date: Thu, 10 Mar 2005 15:49:10 -0500 (EST)

Hi,

Here's something that I'm sure someone else has solved..

I'd like to monitor the number of files in /var/spool/mqueue and do 3
things when it hits a threshold:
- Fire off a warning
- run sendmail -q
- Run a shell command to nuke some things (like SPAM!)

So,  here's what I have now, which seems fairly inelegant:
----BEGIN SNIP
classes:
        # See if we're overlimt
        MailqueOverLimit = ( ReturnsZero(/bin/sh -c "expr `ls /var/spool/mqueue/ | grep 
q.*| wc -l`  \> 12 > /dev/null") )

alerts:
        # Tell us if we're overlimit (it'd be nice to have the actual
        # number...)
        MailqueOverLimit::
                "WARNING: Mail queue is overlimit on $(fqhost)" ifelapsed=60

shellcommands:
        # Do something to make us not overlimit
        MailqueOverLimit::
                "$(nuke_spam_bounces)"
                "$(run_a_qrunner)"
----END SNIP

This seems kinda like a kludge.  Anyone have any better suggestions for
monitoring the number of files in a directory?

Thanks!

-n

--
-------------------------------------------
nathan hruby <nhruby@uga.edu>
uga enterprise information technology services
production systems support
metaphysically wrinkle-free
-------------------------------------------




reply via email to

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