Page 1 of 2
NRPE Unable to read output
Posted: Wed Jan 08, 2020 11:58 am
by mccrakem
Hi
I have a a script that checks the modified date of a file but I receive the above message when I try and run the monitor via the NAGIOS GUI
I have created a cfg file in the /etc/nrpe.d directory
with the contents
#!/bin/bash
dont_blame_nrpe=1
command[check_ucard_backups]=sudo /LOCATION_OF_SCRIPT
The contents of the script is
output=$(sudo /usr/bin/tail -n 1 /opt/IBM/app_users/UDeployUser/lastbackups)
if [[ -z "$(sudo /bin/find /opt/IBM/app_users/UDeployUser/lastbackups -mtime -1)" ]] ; then
echo "CRITICAL - Backup too old"
exit 2
else
echo "OK - Backup is recent"
exit 0
fi
When I run it from the server I get the correct response
OK - Backup is recent
But just not a correct response from the GUI
as a test I have added the nrpe user to the sudoers file so it should be aboe to run a command without being prompted for a password
again this worked ok from the Server but not from the Nagios GUI
Can you take a look and advise
Thanks
Re: NRPE Unable to read output
Posted: Wed Jan 08, 2020 12:51 pm
by tacolover101
could you please post your sudoers on the client running nrpe?
what is the result when you
to the nrpe user, and run
Code: Select all
sudo /usr/bin/tail -n 1 /opt/IBM/app_users/UDeployUser/lastbackups
?
also, do your NRPE logs mention anything? i think on the client side there may be a log per the connection stating more about the issue.
Re: NRPE Unable to read output
Posted: Wed Jan 08, 2020 5:43 pm
by tgriep
Thanks
@tacolover101
One more thing, the NRPE agent installed using the nagios installer, runs as the nagios user account, so run this
Then run your script.
Re: NRPE Unable to read output
Posted: Thu Jan 09, 2020 5:53 am
by mccrakem
Hi
When I try and su - nrpe or to nagios I just get the following message
This account is currently not available
If I cat the /etc/passwd file I do see the nrpe and the nagios users listed in there
nrpe

482:482:NRPE user for the NRPE service:/var/run/nrpe:/sbin/nologin
nagios

:481:481::/var/spool/nagios:/sbin/nologin
Re: NRPE Unable to read output
Posted: Thu Jan 09, 2020 10:26 am
by tgriep
Edit the /etc/passwd file and change the following from
Code: Select all
nrpe:x:482:482:NRPE user for the NRPE service:/var/run/nrpe:/sbin/nologin
nagios:x::481:481::/var/spool/nagios:/sbin/nologin
to
Code: Select all
nrpe:x:482:482:NRPE user for the NRPE service:/var/run/nrpe:/bin/bash
nagios:x::481:481::/var/spool/nagios:/bin/bash
Then see if you can change to the user account and run the script.
Re: NRPE Unable to read output
Posted: Fri Jan 10, 2020 3:46 am
by mccrakem
Hi
When I change the commands to what you mention above
I then su - nrpe or nagios but when I goto run the script I get prompted for the password for each user
Re: NRPE Unable to read output
Posted: Fri Jan 10, 2020 10:00 am
by tgriep
The password cannot be set on those accounts as it will stop the scripts from running as that user.
To remove the password, run this as root.
Code: Select all
passwd --delete nagios
chage -I -1 -m 0 -M 99999 -E -1 nagios
passwd --delete nrpe
chage -I -1 -m 0 -M 99999 -E -1 nrpe
Then run the scripts to see if it works.
Re: NRPE Unable to read output
Posted: Mon Jan 13, 2020 6:38 am
by mccrakem
I ran the above commands as root switched to nrpe user and tried to run the script
but I was prompted again for the nrpe user password
Re: NRPE Unable to read output
Posted: Mon Jan 13, 2020 10:22 am
by tgriep
Lets determine if NRPE is running as the nagios user or the nrpe user.
Run the following commands on the remote server and post the output.
Code: Select all
netstat -anp |grep 5666
ps -ef --cols=300 |grep nrpe
Run this find command to search for the nrpe.cfg file.
Post the full output of the find command and upload the nrpe.cfg file that is found so we can view them.
Or, you can add this to the /etc/sudoers file to enable nrpe and nagios users to run the script and not prompt for the password.
Code: Select all
nagios ALL=NOPASSWD: /LOCATION_OF_SCRIPT
nrpe ALL=NOPASSWD: /LOCATION_OF_SCRIPT
Re: NRPE Unable to read output
Posted: Thu Jan 16, 2020 10:29 am
by mccrakem
When I did the above steps when I tried to su to the nrpe user I was still prompted for a password