Is the nagios user not able to run df? Can you try removing the sudo in the df commands?
You might try putting an echo something and exit 0 at the top of the script to see what happens. If nothing changes, the trouble isn't in the script...
#!/bin/bash
echo testing
exit 0
NRPE: Unable to read output only fails on custom script
Re: NRPE: Unable to read output only fails on custom script
@lee.krause, let us know how @gormank's instructions worked for you. Thanks!
Former Nagios Employee.
me.
me.
-
- Posts: 86
- Joined: Wed Jan 20, 2016 8:38 am
Re: NRPE: Unable to read output only fails on custom script
Sorry I've been away from the office.
I added the following to the sudoers file:
Cmnd_Alias NAG = /usr/bin/grep, \
/usr/bin/df
nagios ALL=(root) NOPASSWD:NAG
I also tried removing the sudo from the script but have the same result.
When the check_nrpe script is initiated, does it run "su nagios"?
I added the following to the sudoers file:
Cmnd_Alias NAG = /usr/bin/grep, \
/usr/bin/df
nagios ALL=(root) NOPASSWD:NAG
I also tried removing the sudo from the script but have the same result.
When the check_nrpe script is initiated, does it run "su nagios"?
Re: NRPE: Unable to read output only fails on custom script
The check_nrpe runs as whatever user nagios is running as, which is usually 'nagios'. NRPE will use the 'nrpe_user' in nrpe.cfg unless it's running under inetd, in which case it will run as 'root' or whatever user is specified in the inetd config.When the check_nrpe script is initiated, does it run "su nagios"?
Let's try the following:# NRPE USER
# This determines the effective user that the NRPE daemon should run as.
# You can either supply a username or a UID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
nrpe_user=nagios
# NRPE GROUP
# This determines the effective group that the NRPE daemon should run as.
# You can either supply a group name or a GID.
#
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
nrpe_group=nagios
On the remote box
1. Create a test script, for example named "check_test.sh", and set permissions.
Code: Select all
#!/bin/bash
echo $1
exit 0
2. Add the command to the nrpe.cfg file:
Code: Select all
command[check_test]=/etc/nagios/nrpe/check_test.sh $ARG1
Test the check on the Nagios box (example):
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_test -a 'testing'
testing
echo $?
0
Be sure to check out our Knowledgebase for helpful articles and solutions!