NRPE command doesn't work when called from remote host
Posted: Mon Dec 08, 2014 6:51 am
Hello,
first of all: I know there were already questions about this issue, but even using their answers I still cannot figure out why my command is not working.
What I want to do is call a script on remote host using NRPE. However, this what the script is going to do may be only executed by specific user: tomcat.
I tried even the least secure solution, just to make it work - with no luck unfortunately.
1. My nrpe.cfg has entry:
2. Script /usr/local/bin/debug_now looks like:
3. My sudoers on host, where I try to execute this script:
I also tried but as it was not working I went for ALL.
4.Permissions
which is the same as all other scripts in this directory; all of them work fine, none of them needs to use sudo though.
5. Output when run in local shell as nagios
6. Output when run from remote host using NRPE
As you can see, the line where user nagios has to do something as user tomcat is not showing at all.
I'm pretty sure I covered everything but still something is missing. Could you try to point me out my problem?
EDIT.
If this may be useful - I use Debian 6.0.7, Nagios 3.2.0, NRPE v2.12
first of all: I know there were already questions about this issue, but even using their answers I still cannot figure out why my command is not working.
What I want to do is call a script on remote host using NRPE. However, this what the script is going to do may be only executed by specific user: tomcat.
I tried even the least secure solution, just to make it work - with no luck unfortunately.
1. My nrpe.cfg has entry:
Code: Select all
command[debug_now]=/usr/local/bin/debug_nowCode: Select all
#!/bin/sh
whoami
echo "Debug..."
sudo -u tomcat whoami
echo "Debug finished"Code: Select all
Defaults env_reset
Defaults !requiretty
root ALL=(ALL) ALL
(...) a few not relevant users
nagios ALL=(ALL) NOPASSWD: ALL
%tomcat ALL=(ALL) NOPASSWD: /bin/su - tomcat
%tomcat ALL=(ALL) NOPASSWD: /etc/init.d/tomcat stop
%tomcat ALL=(ALL) NOPASSWD: /etc/init.d/tomcat start
%tomcat ALL=(ALL) NOPASSWD: /etc/init.d/tomcat restartCode: Select all
nagios ALL=(tomcat)4.Permissions
Code: Select all
-rwxr-xr-x 1 root staff 582 Dec 2 11:11 /usr/local/bin/debug_now5. Output when run in local shell as nagios
Code: Select all
~$ sudo -u nagios /usr/local/bin/debug_now
nagios
Debug...
tomcat
Debug finished
Code: Select all
~$ /usr/lib/nagios/plugins/check_nrpe -H (... ip here) -c debug_now
nagios
Debug...
Debug finished
I'm pretty sure I covered everything but still something is missing. Could you try to point me out my problem?
EDIT.
If this may be useful - I use Debian 6.0.7, Nagios 3.2.0, NRPE v2.12