NRPE Unable to read output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
mccrakem
Posts: 129
Joined: Mon Jun 19, 2017 8:28 am

NRPE Unable to read output

Post 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
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: NRPE Unable to read output

Post by tacolover101 »

could you please post your sudoers on the client running nrpe?

what is the result when you

Code: Select all

su
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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE Unable to read output

Post by tgriep »

Thanks @tacolover101

One more thing, the NRPE agent installed using the nagios installer, runs as the nagios user account, so run this

Code: Select all

su - nagios
Then run your script.

Code: Select all

sudo /LOCATION_OF_SCRIPT
Be sure to check out our Knowledgebase for helpful articles and solutions!
mccrakem
Posts: 129
Joined: Mon Jun 19, 2017 8:28 am

Re: NRPE Unable to read output

Post 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:x:482:482:NRPE user for the NRPE service:/var/run/nrpe:/sbin/nologin
nagios:x::481:481::/var/spool/nagios:/sbin/nologin
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE Unable to read output

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
mccrakem
Posts: 129
Joined: Mon Jun 19, 2017 8:28 am

Re: NRPE Unable to read output

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE Unable to read output

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
mccrakem
Posts: 129
Joined: Mon Jun 19, 2017 8:28 am

Re: NRPE Unable to read output

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE Unable to read output

Post 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.

Code: Select all

find / -name nrpe.cfg
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
Be sure to check out our Knowledgebase for helpful articles and solutions!
mccrakem
Posts: 129
Joined: Mon Jun 19, 2017 8:28 am

Re: NRPE Unable to read output

Post by mccrakem »

When I did the above steps when I tried to su to the nrpe user I was still prompted for a password
Locked