"Fossies" - the Fresh Open Source Software Archive

Member "unix/plugins/files_indir" (15 Sep 2021, 1053 Bytes) of package /linux/misc/pandorafms_agent_unix-7.0NG.757.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 # Syntax:
    4 #
    5 # Directory_Name : Directory to check
    6 
    7 if [ -z "$1" ]
    8 then
    9     echo "You need too pass target directory to monitor"
   10     echo "Plugin will report CRITICAL if previous number"
   11     echo "of files in directory is greater than actual number"
   12     exit
   13 fi
   14 
   15 DIRE=$1
   16 if [ `uname -s` = "FreeBSD" ];then
   17     DIRETMP=`echo $DIRE | /sbin/md5`;
   18 else
   19     DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'`
   20 fi
   21 DIRETMP=/tmp/$DIRETMP
   22 
   23 CURRENT=`ls -la ${DIRE} | wc -l | tr -d ' '`
   24 
   25 if [ -e $DIRETMP ]
   26 then
   27     ANTERIOR=`cat $DIRETMP`
   28 else
   29     ANTERIOR=0
   30 fi
   31 
   32 if [ $ANTERIOR -gt $CURRENT ]
   33 then
   34     DISPARA=0
   35 else
   36     DISPARA=1
   37 fi
   38 
   39 echo $CURRENT > $DIRETMP
   40 
   41 echo "<module>
   42     <name><![CDATA[FS_$DIRE]]></name>
   43     <description><![CDATA[Number of files in directory]]></description>
   44     <type><![CDATA[generic_proc]]></type>
   45     <data><![CDATA[$DISPARA]]></data>
   46 </module>
   47 
   48 <module>
   49     <name><![CDATA[NumFiles_FS_$DIRE]]></name>
   50     <description><![CDATA[Number of files]]></description>
   51     <type><![CDATA[generic_data]]></type>
   52     <data><![CDATA[$CURRENT]]></data>
   53 </module>"
   54