Code: Select all
nrpe_user=nagios
nrpe_group=nagios
Code: Select all
Defaults:nagios !requiretty
nagios ALL=(ALL) NOPASSWD: ALL
Code: Select all
nrpe_user=nagios
nrpe_group=nagios
Code: Select all
Defaults:nagios !requiretty
nagios ALL=(ALL) NOPASSWD: ALL
Code: Select all
command[check_sudo_test2]=sudo env
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_sudo_test2
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
LOGNAME=root
USER=root
HOME=/root
SHELL=/bin/bash
TERM=unknown
SUDO_COMMAND=/usr/bin/env
SUDO_USER=nagios
SUDO_UID=115
SUDO_GID=122
Code: Select all
nagios@MYMACHINE[~]> sudo env
LANG=de_DE.UTF-8
TERM=screen
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
LOGNAME=root
USER=root
HOME=/root
SHELL=/bin/bash
SUDO_COMMAND=/usr/bin/env
SUDO_USER=nagios
SUDO_UID=115
SUDO_GID=122
Unfortunately this is not an option since we have a global rollout for NRPE. Our entire Monitoring-infrastructure relies on NRPE.Perhaps you could try using another agent like NCPA and see if it works that way.
Code: Select all
#!/bin/bash
echo "test.sh start"
sudo jstat -gc 1314 | tail -1 | sed -e 's/[ ][ ]*/ /g' > /tmp/check_test.log 2>&1
echo "test.sh stop"
exit 5
Code: Select all
command[check_test]=echo "nrpe command begin" || sudo /usr/lib/nagios/plugins/check_test.sh || echo "nrpe command end"
Code: Select all
nagios@nagios[/usr/local/nagios/libexec]> ./check_nrpe -H x.x.x.x -c check_test
nrpe command begin
Code: Select all
Feb 21 08:07:59 p083 nrpe[23870]: Connection from 1.2.3.4 port 63192
Feb 21 08:07:59 p083 nrpe[23870]: Host address is in allowed_hosts
Feb 21 08:07:59 p083 nrpe[23870]: Host 1.2.3.4 is asking for command 'check_test' to be run...
Feb 21 08:07:59 p083 nrpe[23870]: Running command: echo "nrpe command begin" || sudo /usr/lib/nagios/plugins/check_test.sh || echo "nrpe command end"
Feb 21 08:07:59 p083 nrpe[23870]: Command completed with return code 0 and output: nrpe command begin
Feb 21 08:07:59 p083 nrpe[23870]: Return Code: 0, Output: nrpe command begin
Feb 21 08:07:59 p083 nrpe[23870]: Connection from 1.2.3.4 closed.
Code: Select all
#!/bin/bash
echo "test.sh start" >> /tmp/check_test.log 2>&1
sudo jstat -gc 1314 | tail -1 | sed -e 's/[ ][ ]*/ /g' >> /tmp/check_test.log 2>&1
echo "test.sh stop" >> /tmp/check_test.log 2>&1
exit 5
Yes, this is intended (for testing purposes). When initially debugging my issue I nailed the problem down to be the call of the jstat-binary.Also just to confirm, you're starting off using the check_jstat.sh plugin, and then when you move to check_test.sh, check_test.sh is using the straight up jstat command, not the check_jstat.sh plugin. Is that intended?
Code: Select all
grep nagios /etc/sudoers
Code: Select all
grep nagios /etc/sudoers
Defaults:nagios !requiretty
nagios ALL=(ALL) NOPASSWD: ALL
Code: Select all
ls -l /usr/lib/nagios/plugins/check_test.sh