Plugin does not work with nrpe

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rockburry
Posts: 5
Joined: Thu Apr 24, 2014 3:17 am

Plugin does not work with nrpe

Post by rockburry »

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
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Plugin does not work with nrpe

Post by hsmith »

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.
rockburry
Posts: 5
Joined: Thu Apr 24, 2014 3:17 am

Re: Plugin does not work with nrpe

Post by rockburry »

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 :-(
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Plugin does not work with nrpe

Post by hsmith »

What does the command line report back?
Former Nagios Employee.
me.
rockburry
Posts: 5
Joined: Thu Apr 24, 2014 3:17 am

Re: Plugin does not work with nrpe

Post by rockburry »

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!)
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Plugin does not work with nrpe

Post by hsmith »

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.
rockburry
Posts: 5
Joined: Thu Apr 24, 2014 3:17 am

Re: Plugin does not work with nrpe

Post by rockburry »

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
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Plugin does not work with nrpe

Post by hsmith »

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.
rockburry
Posts: 5
Joined: Thu Apr 24, 2014 3:17 am

Re: Plugin does not work with nrpe

Post by rockburry »

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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Plugin does not work with nrpe

Post by tmcdonald »

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
Locked