Solved NRPE2 paths set up; python(+other) plugins

How can I add PATH variable to NRPE2?

My problem is that I have several python written plugins and they do not work in jails.

I have created quick workaround. A symlink /usr/bin/python2 -> /usr/local/bin/python2 , but I am not sure if this a proper way doing things as machine is jailed and I am sharing path with a basejail.

Without symlink I am ending up with :

Code:
root@monitor018:/usr/local/nagios/libexec# ./check_nrpe -H 10.113.113.123 -c check_mongo
NRPE: Unable to read output

I did some debugging and find out that NRPE2 does not set up proper paths.

created test file in /usr/local/libexec/nagios/check_testme on a target machine
Code:
#!/bin/sh
echo -------------------
env
echo -------------------
whoami
echo -------------------

Adjust /usr/local/etc/nrpe.conf with:
Code:
command[check_testme]=/usr/local/libexec/nagios/check_testme
allow_bash_command_substitution=1
allowed_hosts=127.0.0.1,10.24.14.41
command_timeout=60
connection_timeout=300
debug=0
dont_blame_nrpe=1
log_facility=daemon
nrpe_group=nagios
nrpe_user=nagios
pid_file=/var/run/nrpe2/nrpe2.pid
server_port=5666

Restarted NRPE
service nrpe2 restart

On the nagios machine(Linux) I did this
Code:
root@monitor023:/usr/local/nagios/libexec# ./check_nrpe -H 10.113.113.123 -c check_testme
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/
HOME=/
NRPE_PROGRAMVERSION=2.15
NRPE_MULTILINESUPPORT=1
RC_PID=49882
-------------------
nagios
-------------------

Code:
root@product:/usr/local/etc # uname -a
FreeBSD product 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

Result shows that there is no path to fit with python (/usr/local/bin/python).

Does anyone had similar issue or know how to add paths to NRPE2?
 
Is that the only command that isn't working? What's in the very first line of the script? It may just need the shebang fix committed to that port so it refers to the correct Python command.
 
All plugins using python or bash, like this one check_mongo. Adding full path for python does not help.
Code:
# cat /usr/local/libexec/nagios/check_mongodb1
#!/usr/bin/env python2
print "HI"
exit(0)

gives:
Code:
# ./check_nrpe -H 10.113.113.123 -c check_mongodb1
NRPE: Unable to read output
 
I don't run this so all I can do is get a "connection denied" instead of an "unable to read output". If you can find there is something wrong with the configuration of the port then we can see about was needs to be fixed.

...
I have created quick workaround. A symlink /usr/bin/python2 -> /usr/local/bin/python2 , but I am not sure if this a proper way doing things as machine is jailed and I am sharing path with a basejail.
...
...
Adding full path for python does not help.
...

If I understand this correctly, ln -s /usr/local/bin/python2 /usr/bin/python2 fixes your problem but a full path of #!/usr/local/bin/python2 in the shebang line of the script does not?
 
Found a solution. Reinstalling NRPE + NAGIOS-PLUGINS has fixed a problem. I suspect something wrong has happened during 10.2 upgrade. I am afraid I have no track of that anymore...

-------
Correct. What I did exactly was ln -s /usr/jails/basejail/bin/python2 /usr/bin/python2 outside a jail. Now the link is available to all jails.

- I found that there was no changes to net-mgmt/nrpe package.
- #!/usr/local/bin/python2 in the shebang line does not work (even python installed)
- login.conf is default.
- This happen to all jailed machines on that box
 
Back
Top