Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have written a small script to check the states of PfSense, and using this script to get the output in nagios, through NRPE...

Here is the script

used=`pfctl -s state | wc -l | bc | cut -c1-5 | bc`

echo "States consumed=$used"

Normal output of the script is as follows (as it runs on the client.

States consumed=25519

But the issue is that when the same script is ran through NRPE from the nagios server, I get this command.

States consumed=0

But when I put anything in the variable "used" , for example pass it value of 123, or abc,,it is visible on the nagios server through nrpe... What can be the issue here? I have tried every possible solution from my side, since last 5 days..

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Is "pfctl" in the PATH for nagios user? I would use the absolute path in the script.

share|improve this answer
    
yes, thats why i am getting an output, otherwise script wont run at all –  Farhan Jan 3 '12 at 12:15
    
I don't mean the check script called by nrpe. I mean the pfctl command itself (I'm not familiar with FreeBSD, so I don't know if that's standard, or if it's in /usr/sbin and /usr/sbin isn't in the default PATH for nagios user). From what you've pasted, you're calling "pfctl" and assuming that the nagios user can find it in its PATH. –  cjc Jan 3 '12 at 12:22
    
got it. i am running it with /sbin/pfctl ...now i have added the nrpe user to WHEELS group, but still nrpe is unable to run the command pfctl.. –  Farhan Jan 3 '12 at 13:26
1  
You may have to invoke your script using sudo. You can restrict nagios user to only that command run by adding something like this to the sudoers file: "nagios ALL=(ALL) NOPASSWD: /path/to/script" and then changing your nrpe.cfg so that you're running "sudo /path/to/script". See if that works. It's possible pfctl won't run as non-root, even with a user in the right group. Again, I'm not a BSD user so I'm not sure if that's the case. –  cjc Jan 3 '12 at 13:44
    
i was trying not to use sudo, but as it was last resort, that i had left with..so its working now. Thanks –  Farhan Jan 3 '12 at 14:50
add comment

Is it because of the user that the script runs as?

share|improve this answer
    
the permission of script is 777, which means anyone can execute this command. but with which user nrpe runs the scripts? –  Farhan Jan 3 '12 at 12:14
    
What user is the nrpe daemon running as? That's the user that will run the script. –  MadHatter Jan 3 '12 at 13:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.