Page 1 of 1

Nagios debug for running NRPE commands

Posted: Fri Jul 14, 2017 9:33 am
by snapon_admin
What is the best way to find out exactly what is happening when a service check is ran from the Nagios server? We have a script that needs root permissions to run on our Unix servers, and this check used to work when ran from Nagios via NRPE. Recently we tried doing something similar by adding a script to check some things for goldengate, but this script needed to be ran as a different user than Nagios. We couldn't get this one to work when the command was issued from the Nagios server, but running the script from the Unix server as the Nagios user would work fine. After that, the other check we have that needs root permissions suddenly stopped working. And again, this other script works when you run it from the server as Nagios, it gets the necessary root perms and runs fine, but when it runs from the Nagios server via NRPE, nothing.

Re: Nagios debug for running NRPE commands

Posted: Fri Jul 14, 2017 11:33 am
by lmiltchev
What is the version of NRPE that you are currently using?

Usually, you would need to check the system log in the client to troubleshoot issues like this one.

On my test box, I am using NRPE Version: 3.2.0, and I do have the following options set up in the "/usr/local/nagios/etc/nrpe.cfg":

Code: Select all

# LOG FILE
# If a log file is specified in this option, nrpe will write to
# that file instead of using syslog.

#log_file=${prefix}/var/nrpe.log
log_file=/usr/local/nagios/var/nrpe.log


# DEBUGGING OPTION
# This option determines whether or not debugging messages are logged to the
# syslog facility.
# Values: 0=debugging off, 1=debugging on

debug=1
This way, I have a "dedicated" log file for NRPE that I can check in case I run into some issues.

What kind of error do you see when you run the actual check from the CLI?

Re: Nagios debug for running NRPE commands

Posted: Mon Aug 07, 2017 10:50 am
by snapon_admin
Sorry for the delayed reply, we ended up deciding to go a different route with this check. I'm bringing this back up again, though, because we're trying this on another check. Running the script on the client as Nagios works, but running from the Nagios server via NRPE does not. We're not getting an error really, the script itself seems to be running but it's not returning any data so it looks like the permissions are not being assigned properly.

Running the script from the client as user Nagios:

Code: Select all

kentest14g$  /vendor/nagios/opt/csw/libexec/nagios-plugins/check-process-memory-utilization.ksh -c 95 -w 90
PROCESS MEMORY OK : kentest14g Process Memory is 42.19% | PROC_MEM=42.19;90;95;0;100;MEMORY_ALLOCATED=1.82;3.60;3.80;0;4.00;MEMORY_USED=1.69;3.60;3.80;0;4.00;
</vendor/nagios>
kentest14g$ id
uid=14051(nagios) gid=14051(nagios)
Running from Nagios XI server:

Code: Select all

[root@lisl-ngos-01-pv libexec]# ./check_nrpe -H kentest14g.snapon.com -p 5668 -t 70 -c check_process-memory -a '-w 90 -c 95'
PROCESS MEMORY OK : kentest14g Process Memory is % | PROC_MEM=;90;95;0;100;MEMORY_ALLOCATED=0.00;;;0;0.00;MEMORY_USED=0.00;;;0;0.00;

Re: Nagios debug for running NRPE commands

Posted: Mon Aug 07, 2017 4:12 pm
by tgriep
Can you post the script here so we can view it?
Does running the script require any environment variables?

You could try adding an entry in the /etc/sudoers file to the script will run as root.

Code: Select all

nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_mem
Also, you can add sudo in from of the command in the nrpe.cfg file and see if that works.

Code: Select all

command[check_mem]= sudo /usr/local/nagios/libexec/check_mem
Adjust the settings if necessary.