Page 1 of 1
Problem with script.
Posted: Wed Mar 04, 2015 7:15 am
by jmasquelet
Hi, i've Nagios 3 and i'm tryin to put a script in a host.
Script run OK on sh, ksh, bash but when running from Nagios server always return OK.
nagios@sdd11:/usr/lib/nagios/plugins> ./check_nrpe -H sd1 -c check_informix
ok
nagios@sdd11:/usr/lib/nagios/plugins> ./check_informix.sh
NOOO
#!/bin/sh
estado="$(/opt/mw/bin/ifxcheck tarcred sdd narplus meta4)"
tarcred=$(echo $estado | cut -d" " -f1)
if [[ "$tarcred" -ge 30 ]];then
alarma=1
fi
if [[ $alarma -eq 1 ]];then
echo "NOOO"
exit 2
else
echo "ok"
exit 0
fi
Re: Problem with script.
Posted: Wed Mar 04, 2015 10:07 am
by jmasquelet
ok thanks for post my problem!!!
i know where is the problem:
estado="$(/opt/mw/bin/ifxcheck tarcred sdd narplus meta4)"
it execute ifxcheck but it look like it's not passing the arguments (tarcred sdd narplus meta4) how can i do to pass it?
Re: Problem with script.
Posted: Wed Mar 04, 2015 12:08 pm
by abrist
Can you post the nrpe command directive for check_informix?
Also, is "sd1" the localhost, or another remote box?
jmasquelet wrote:
nagios@sdd11:/usr/lib/nagios/plugins> ./check_nrpe -H sd1 -c check_informix
ok
Re: Problem with script.
Posted: Wed Mar 04, 2015 12:16 pm
by jmasquelet
its localhost.
./check_nrpe -H localhost -c check_informix
Re: Problem with script.
Posted: Wed Mar 04, 2015 12:43 pm
by abrist
Can you add a few echos to the script and then rerun it through nrpe and from the command line? (post the results)
Code: Select all
#!/bin/sh
estado="$(/opt/mw/bin/ifxcheck tarcred sdd narplus meta4)"
echo "$estado"
tarcred=$(echo $estado | cut -d" " -f1)
echo "tarcred"
if [[ "$tarcred" -ge 30 ]];then
alarma=1
fi
if [[ $alarma -eq 1 ]];then
echo "NOOO"
exit 2
else
echo "ok"
exit 0
fi
And then run:
Code: Select all
./check_nrpe -H localhost -c check_informix
./check_informix
Re: Problem with script.
Posted: Wed Mar 04, 2015 8:57 pm
by jmasquelet
result for ./check_informix.sh
nagios@sdd11:/usr/lib/nagios/plugins> ./check_informix.sh
622 72 53 335
622
NOOO
result for ./check_nrpe -H localhost -c check_informix
nagios@sdd11:/usr/lib/nagios/plugins> ./check_nrpe -H localhost -c check_informix
ok
Re: Problem with script.
Posted: Thu Mar 05, 2015 1:52 pm
by jolson
If SELinux is on, does this work with SELinux turned off?
Code: Select all
setenforce 0
./check_nrpe -H localhost -c check_informix
Since there are two blank spaces above your 'ok' in the second example, that means there is no output value for the echoes abris suggested. It looks like when the script is run via NRPE it cannot check "/opt/mw/bin/ifxcheck".
Since the Nagios user
can check '/opt/mw/bin/ifxcheck' properly on the command line, that leads me to believe that SELinux is a possible culprit.
If that does not help, could you please post the results of the following commands:
Code: Select all
cat /etc/xinetd.d/nrpe.conf
cat /usr/local/nagios/etc/nrpe.cfg