2011-12-07 11:07:43 +01:00
|
|
|
#!/bin/sh
|
2010-01-27 13:52:02 +01:00
|
|
|
|
|
|
|
# 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
|
2011-12-07 11:07:43 +01:00
|
|
|
if [ `uname -s` = "FreeBSD" ];then
|
|
|
|
DIRETMP=`echo $DIRE | /sbin/md5`;
|
|
|
|
else
|
|
|
|
DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'`
|
|
|
|
fi
|
2010-01-27 13:52:02 +01:00
|
|
|
DIRETMP=/tmp/$DIRETMP
|
|
|
|
|
2011-12-07 11:07:43 +01:00
|
|
|
CURRENT=`ls -la ${DIRE} | wc -l | tr -d ' '`
|
2010-01-27 13:52:02 +01:00
|
|
|
|
|
|
|
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 "<module>
|
|
|
|
<name><![CDATA[FS_$DIRE]]></name>
|
2015-07-07 12:43:34 +02:00
|
|
|
<description><![CDATA[Number of files in directory]]></description>
|
|
|
|
<type><![CDATA[generic_proc]]></type>
|
|
|
|
<data><![CDATA[$DISPARA]]></data>
|
2010-01-27 13:52:02 +01:00
|
|
|
</module>
|
|
|
|
|
|
|
|
<module>
|
|
|
|
<name><![CDATA[NumFiles_FS_$DIRE]]></name>
|
2015-07-07 12:43:34 +02:00
|
|
|
<description><![CDATA[Number of files]]></description>
|
|
|
|
<type><![CDATA[generic_data]]></type>
|
|
|
|
<data><![CDATA[$CURRENT]]></data>
|
2010-01-27 13:52:02 +01:00
|
|
|
</module>"
|
|
|
|
|