Problem with script.

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
jmasquelet
Posts: 15
Joined: Wed Mar 04, 2015 6:37 am

Problem with script.

Post 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
jmasquelet
Posts: 15
Joined: Wed Mar 04, 2015 6:37 am

Re: Problem with script.

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Problem with script.

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jmasquelet
Posts: 15
Joined: Wed Mar 04, 2015 6:37 am

Re: Problem with script.

Post by jmasquelet »

its localhost.

./check_nrpe -H localhost -c check_informix
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Problem with script.

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jmasquelet
Posts: 15
Joined: Wed Mar 04, 2015 6:37 am

Re: Problem with script.

Post 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
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Problem with script.

Post 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
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
Locked