#!/bin/sh # Syntax: # # Directory_Name : Directory to check if [ -z "$1" ] then echo "You need too pass target directory to monitor" echo "Plugin will report CRITICAL if previous number" echo "of files in directory is greater than actual number" exit fi DIRE=$1 if [ `uname -s` = "FreeBSD" ];then DIRETMP=`echo $DIRE | /sbin/md5`; else DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'` fi DIRETMP=/tmp/$DIRETMP CURRENT=`ls -la ${DIRE} | wc -l | tr -d ' '` if [ -e $DIRETMP ] then ANTERIOR=`cat $DIRETMP` else ANTERIOR=0 fi if [ $ANTERIOR -gt $CURRENT ] then DISPARA=0 else DISPARA=1 fi echo $CURRENT > $DIRETMP echo " Number of files in directory generic_proc $DISPARA Number of files generic_data $CURRENT "