Run netstat using NRPE failed

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.
yanivhs
Posts: 6
Joined: Wed Oct 23, 2013 7:11 am

Run netstat using NRPE failed

Post 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
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Run netstat using NRPE failed

Post 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.
yanivhs
Posts: 6
Joined: Wed Oct 23, 2013 7:11 am

Re: Run netstat using NRPE failed

Post 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
Attachments
check_netstat.sh.txt
(751 Bytes) Downloaded 442 times
nrpe.cpg.txt
(8.11 KiB) Downloaded 407 times
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Run netstat using NRPE failed

Post by tmcdonald »

Your script is wrong. Try the one I attached.

Also, what is the check command you are actually executing from Nagios?
Attachments
check_netstat.sh.txt
(722 Bytes) Downloaded 480 times
Former Nagios employee
yanivhs
Posts: 6
Joined: Wed Oct 23, 2013 7:11 am

Re: Run netstat using NRPE failed

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

Re: Run netstat using NRPE failed

Post by abrist »

yaniv@ashnav.co.il wrote:/usr/lib64/nagios/plugins/check_netstat.sh: line 22: su: command not found
Do you have 'su'?

Code: Select all

which su
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.
yanivhs
Posts: 6
Joined: Wed Oct 23, 2013 7:11 am

Re: Run netstat using NRPE failed

Post by yanivhs »

Yes, I have su

/bin/su
Permissions :
-rwsr-xr-x. 1 root root 34904 May 23 14:00 /bin/su
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Run netstat using NRPE failed

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
yanivhs
Posts: 6
Joined: Wed Oct 23, 2013 7:11 am

Re: Run netstat using NRPE failed

Post by yanivhs »

Tried that, but I'm getting a permission denied

/bin/su: Permission denied
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Run netstat using NRPE failed

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked