Page 1 of 2

Run netstat using NRPE failed

Posted: Wed Oct 23, 2013 7:21 am
by yanivhs
Hello

I've created a simple script to check established connection number.
The script runs fine, but when I'm trying to run it using NRPE, I'm getting "OK, 0 connections " instead of the real connection number.
I've added the sudo to the command configuration in nrpe.cgf, and now I'm getting "sh: /usr/bin/sudo: Permission denied"

What I'm doing wrong?

Both systems are centos 6.4 and the nagios version is 4

Thanks

Re: Run netstat using NRPE failed

Posted: Wed Oct 23, 2013 10:43 am
by slansing
Can you share your script with us so we can see what may be causing this? Without that we can only guess.

You should not need sudo for the nrpe.cfg it's read by the nagios user and the permissions on it should reflect that.

Re: Run netstat using NRPE failed

Posted: Thu Oct 24, 2013 1:16 am
by yanivhs
Here are the scripts

nrpe.cfg

My script ( located at /usr/lib64/nagios/plugins )
I've also tried copying the netstat file to the plugins directory, but with same results.

Thanks
Yaniv

Re: Run netstat using NRPE failed

Posted: Thu Oct 24, 2013 4:21 pm
by tmcdonald
Your script is wrong. Try the one I attached.

Also, what is the check command you are actually executing from Nagios?

Re: Run netstat using NRPE failed

Posted: Sun Oct 27, 2013 2:13 am
by yanivhs
Running the attached one I'm getting :
/usr/lib64/nagios/plugins/check_netstat.sh: line 22: su: command not found
/usr/lib64/nagios/plugins/check_netstat.sh: line 24: [: -lt: unary operator expected
/usr/lib64/nagios/plugins/check_netstat.sh: line 33: [: -gt: unary operator expected
/usr/lib64/nagios/plugins/check_netstat.sh: line 42: [: -gt: unary operator expected


From the nagios server I'm executing "check_nrpe -H 10.4.4.30 -c check_netstat 32 64" ( from the terminal )

Re: Run netstat using NRPE failed

Posted: Mon Oct 28, 2013 12:07 pm
by abrist
[email protected] wrote:/usr/lib64/nagios/plugins/check_netstat.sh: line 22: su: command not found
Do you have 'su'?

Code: Select all

which su

Re: Run netstat using NRPE failed

Posted: Tue Oct 29, 2013 1:59 am
by yanivhs
Yes, I have su

/bin/su
Permissions :
-rwsr-xr-x. 1 root root 34904 May 23 14:00 /bin/su

Re: Run netstat using NRPE failed

Posted: Tue Oct 29, 2013 1:11 pm
by sreinhardt
Is /bin/bash actually a bash shell or linked to another shell? It seems that it does not contain standard operators that bash should. You might hard code su to /bin/su on line 21 and see if that resolves not finding it.

Re: Run netstat using NRPE failed

Posted: Wed Oct 30, 2013 7:01 am
by yanivhs
Tried that, but I'm getting a permission denied

/bin/su: Permission denied

Re: Run netstat using NRPE failed

Posted: Wed Oct 30, 2013 1:32 pm
by sreinhardt
Out of curiosity, do you have selinux enabled or any other restrictive security systems? Unless you have got some very strange permissions setup, I have never heard of su and sudo being inaccessible to a user. They certainly may not allow elevated rights if the user does not have permission, but thats far from being denied read\execute permission.