NRPE Unable to read output
NRPE Unable to read output
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
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
- tacolover101
- Posts: 432
- Joined: Mon Apr 10, 2017 11:55 am
Re: NRPE Unable to read output
could you please post your sudoers on the client running nrpe?
what is the result when you to the nrpe user, and run ?
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.
what is the result when you
Code: Select all
suCode: Select all
sudo /usr/bin/tail -n 1 /opt/IBM/app_users/UDeployUser/lastbackupsalso, 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
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.
One more thing, the NRPE agent installed using the nagios installer, runs as the nagios user account, so run this
Code: Select all
su - nagiosCode: Select all
sudo /LOCATION_OF_SCRIPTBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NRPE Unable to read output
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
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
nagios
Re: NRPE Unable to read output
Edit the /etc/passwd file and change the following from
to
Then see if you can change to the user account and run the script.
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/nologinCode: 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/bashBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NRPE Unable to read output
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
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
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.
Then run the scripts to see if it works.
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 nrpeBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NRPE Unable to read output
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
but I was prompted again for the nrpe user password
Re: NRPE Unable to read output
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.
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.
Run the following commands on the remote server and post the output.
Code: Select all
netstat -anp |grep 5666
ps -ef --cols=300 |grep nrpePost 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.cfgCode: Select all
nagios ALL=NOPASSWD: /LOCATION_OF_SCRIPT
nrpe ALL=NOPASSWD: /LOCATION_OF_SCRIPTBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NRPE Unable to read output
When I did the above steps when I tried to su to the nrpe user I was still prompted for a password