From 71078bec1f8d0078f65a6d630df2a6b0a44d11ca Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 27 Jan 2010 12:52:02 +0000 Subject: [PATCH] 2010-01-27 Sancho Lerena * plugins/files_indir: New agent to detect if files in a specified directory are less than in previous run. Return two modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2311 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/unix/ChangeLog | 5 +++ pandora_agents/unix/plugins/files_indir | 50 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 pandora_agents/unix/plugins/files_indir diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 42e1f397e7..fd2f2d7d28 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2010-01-27 Sancho Lerena + + * plugins/files_indir: New agent to detect if files in a specficied + directory are less than in previous run. Return two modules. + 2009-12-15 Ramon Novoa * pandora_agent: Removed debugging code. diff --git a/pandora_agents/unix/plugins/files_indir b/pandora_agents/unix/plugins/files_indir new file mode 100755 index 0000000000..6dda84f561 --- /dev/null +++ b/pandora_agents/unix/plugins/files_indir @@ -0,0 +1,50 @@ +#!/bin/bash + +# 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 +DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'` +DIRETMP=/tmp/$DIRETMP + +CURRENT=`ls -la ${DIRE} | wc -l` + +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 +" +