Plugin does not work with nrpe
Posted: Wed Oct 07, 2015 5:32 am
Hi
I need a plugin which should check if a certain file exists in a dirctory. File to be checked is created on daily basis with the date of the last day embedded in it's name. To cut it short, if today is 07102015 then the file name looks like LOG0022206101000.32. Here 32 is again a random number. So I tried to write a small script. Which works fine when executed as a standalone script. But when i run it with check_nrpe, it only shows critical state. Here is the script. May be someone has a better idea. Thanks in advance.
rockburry!!
***************************************************************************
#!/bin/sh
datum=$(date +%d%m%y -d yesterday)
pretext=LOG00
posttext=00
while getopts "p:f:" OPTS; do
case $OPTS in
p)
path="$OPTARG"
;;
f) filiale="$OPTARG"
;;
esac
done
result=$(find $path -iname $pretext$filiale$datum$posttext*)
if [ -f "$result" ]
then
echo "OK : $result 1 Datei existier! Tagesabschluss gelaufen"
exit 0
else
echo "CRITICAL : 0 Datei existiert! Abschluss nicht gelaufen"
exit 1
fi
**************************************************************************
The value of $result is /root/logs/LOG0022206101500.32
I am running nagios 3 and nrpe 2.13
I need a plugin which should check if a certain file exists in a dirctory. File to be checked is created on daily basis with the date of the last day embedded in it's name. To cut it short, if today is 07102015 then the file name looks like LOG0022206101000.32. Here 32 is again a random number. So I tried to write a small script. Which works fine when executed as a standalone script. But when i run it with check_nrpe, it only shows critical state. Here is the script. May be someone has a better idea. Thanks in advance.
rockburry!!
***************************************************************************
#!/bin/sh
datum=$(date +%d%m%y -d yesterday)
pretext=LOG00
posttext=00
while getopts "p:f:" OPTS; do
case $OPTS in
p)
path="$OPTARG"
;;
f) filiale="$OPTARG"
;;
esac
done
result=$(find $path -iname $pretext$filiale$datum$posttext*)
if [ -f "$result" ]
then
echo "OK : $result 1 Datei existier! Tagesabschluss gelaufen"
exit 0
else
echo "CRITICAL : 0 Datei existiert! Abschluss nicht gelaufen"
exit 1
fi
**************************************************************************
The value of $result is /root/logs/LOG0022206101500.32
I am running nagios 3 and nrpe 2.13