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
Plugin does not work with nrpe
Re: Plugin does not work with nrpe
When you run it with check_nrpe, are you testing it vs the command line, or checking it via the gui? Where are you seeing that it is critical?
Former Nagios Employee.
me.
me.
Re: Plugin does not work with nrpe
I tried it both way. On command line, i have the same problem. I have many things like
result=$(find $path -iname $pretext$filiale$datum$posttext* | wc -l)
if [ "$result -eq "1" ]
but it didn't help
result=$(find $path -iname $pretext$filiale$datum$posttext* | wc -l)
if [ "$result -eq "1" ]
but it didn't help
Re: Plugin does not work with nrpe
What does the command line report back?
Former Nagios Employee.
me.
me.
Re: Plugin does not work with nrpe
Only the critical output of my script, as shown below, even if i have the required file in the target directory.
"CRITICAL : 0 Datei existiert! Abschluss nicht gelaufen"
English Translation:
(Critical: 0 File exists. Daily closing did not run!)
"CRITICAL : 0 Datei existiert! Abschluss nicht gelaufen"
English Translation:
(Critical: 0 File exists. Daily closing did not run!)
Re: Plugin does not work with nrpe
Can you switch to the 'nagios' user on the remote machine, and attempt to run the script? I am wondering if you are having some permission errors.
Former Nagios Employee.
me.
me.
Re: Plugin does not work with nrpe
Hi hsmith,
I have added the nagios user in sudoers and given the complete access on the directory where the file has to be searched. But still the same result.
Trying to find an other way to do it. Is there any other plugin that can get file name as argument in regexp with formated date string?
Thanks for your previous feedbacks
RB
I have added the nagios user in sudoers and given the complete access on the directory where the file has to be searched. But still the same result.
Trying to find an other way to do it. Is there any other plugin that can get file name as argument in regexp with formated date string?
Thanks for your previous feedbacks
RB
Re: Plugin does not work with nrpe
So on the remote machine, the one that the script is running on, the user 'nagios' is having issues running the script, but 'root' or whichever user can execute it just fine?
Former Nagios Employee.
me.
me.
Re: Plugin does not work with nrpe
Hi I have analysed this problem a bit further and in my opinion, it does not seem to be the problem of access rights on the Directory. I have noticed, if you see in my script, when I have no double quotes around the variable in if condition, script shows the file name to searched and status is also OK. When i delete the file then script shows no file but status is still OK.
In case i use double quotes around the variable then in script shows only CRITICAL status wether file exists or not.
In case i use double quotes around the variable then in script shows only CRITICAL status wether file exists or not.
Re: Plugin does not work with nrpe
Try running the command with bash -x in front to enable debugging, then run the script and post the output here. That will show exactly what is being executed.
Former Nagios employee