Wednesday 29 April 2009

nagios directory update plugin

nagios plugin for checking a directory is updated. You need to give two argument first for directory and second for minutes.

PROGNAME=`basename $0`
PROGPATH=`echo $0 sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/utils.sh

SEARCH=$1
MIN=$2
COUNT=$(find $1 -mmin -$2 wc -l sed -e 's/ //g' )


if [[ $COUNT -eq 0 ]]
then
echo "NOK " $SEARCH $COUNT "" $SEARCH"COUNT="$COUNT";;;; "
exit $STATE_CRITICAL
else
echo "OK " $SEARCH $COUNT "" $SEARCH"COUNT="$COUNT";;;;"
exit $STATE_OK
fi

No comments: