AW: Plugin for counting files?

Helmut Januschka h.januschka at krone.at
Wed Aug 4 12:21:03 CEST 2004


We are using, check_files_in_dir for checking exim/sendmail queue directories 


call it with  "-h"

#-----------snip

#!/bin/bash

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.0 $' | sed -e 's/[^0-9.]//g'`

. $PROGPATH/utils.sh

print_usage() {
        echo "Check How many files in a Direcotry"
        echo "---------------------Usage-----------------------------------------------"
        echo "-D Directory Def:/usr/local/bannerd/QUEUE";
        echo "-w WARN if greater than N files Def: 20";
        echo "-c CRIT if greater than N files Def: 50";
        echo "-h  Show This Help"
        echo "-------------------------------------------------------------------------"
        print_revision
}


#Defs:
DIRE=/default/dir/
WARN="20";
CRIT="50";

while getopts D:w:c:h o
do
        case $o in
        D) DIRE=$OPTARG;;
        w) WARN=$OPTARG;;
        c) CRIT=$OPTARG;;
        h) print_usage; exit $STATE_UNKOWN;;

        esac


done

CHK=`find $DIRE -type f|wc -l|tr -d [:blank:]`;

if [ $CHK -gt $CRIT ];
then
        echo "FilesInDir($DIRE/$CHK) critical `date`";
        exit $STATE_CRITICAL;
fi;


if [ $CHK -gt $WARN ];
then
        echo "FilesInDir($DIRE/$CHK) warning `date`";
        exit $STATE_WARNING;
fi;

echo "FilesInDir($DIRE/$CHK) ok `date`";
exit $STATE_OK;




#----------snip





-----Ursprüngliche Nachricht-----
Von: Jaap Hogenberg [mailto:jaap.hogenberg at marketxs.com] 
Gesendet: Mittwoch, 04. August 2004 11:23
An: David Knutson
Cc: nagios-users at lists.sourceforge.net
Betreff: Re: [Nagios-users] Plugin for counting files?


On Tue, 2004-08-03 at 18:41, David Knutson wrote:
> Can anyone point me to a plugin for checking the number of files in a 
> directory?  I'm new to nagios and would rather not dive into creating 
> a plugin at this time.  Thanks!
>  
I would encourage you to dive in !
Writing plugins is really quite easy, and will give you
the power to monitor almost anything you could think of.

But I'm in a good mood, so I wrote a plugin for you,
it is attached (shell script, tested to work on a linux 
machine)

Regards,
Jaap.
 


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list