Hi
I have a .sh script that we run on a Unix Server
output=$(sudo /usr/bin/tail -n 1 /opt/NA/app_users/UDeployUser/lastbackups)
if [[ -z "$(sudo /bin/find /opt/NA/app_users/UDeployUser/lastbackups -mtime -1)" ]] ; then
echo "CRITICAL - Backup too old $ouput"
exit 2
else
echo "OK - Backup is recent"
exit 0
fi
When I run this from RHEL I get the following output
OK - Backup is recent
I have it setup in in Nagios
/etc/nrpe.d/check_ucard_backups.cfg
command[check_ucard_backups]=/usr/lib64/nagios/plugins/check_ucard_backups.sh
But when I run it from the NagiosXI GUI I get the following
CRITICAL =- Backup too old
but if I reverse the script like this
output=$(sudo /usr/bin/tail -n 1 /opt/XXXX/app_users/UDeployUser/lastbackup)
if [[ -z "$(sudo /bin/find /opt/XXXX/app_users/UDeployUser/lastbackups -mtime -1)" ]] ; then
echo "OK - Backup is recent"
exit 0
else
echo "CRITICAL - Backup too old $output"
exit 2
fi
Nagios reports back as OK - Backup is recent
To me it looks like Nagios running the script but its stopping at the else and not processing the entire script
Any help with this would be very much appreciated
NagiosXI version 5.2.7
monitoring output from basj script
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: monitoring output from basj script
If I had to guess, I would think that the nagios user doesn't have permissions to run those sudo commands in your script.
I would suggest adding sudo to this
And then adding an entry to your sudoers file giving the nagios user permissions to execute that script as an elevated user
I would suggest adding sudo to this
Code: Select all
command[check_ucard_backups]=sudo /usr/lib64/nagios/plugins/check_ucard_backups.shRe: monitoring output from basj script
Hi Scott
Thanks for the information, but I am not a Unix person can yo0u help me out and let me know what command I should but into the nrpe.cfg file for Nagios to be able to sudo to the correct user and run the script
Thanks
Thanks for the information, but I am not a Unix person can yo0u help me out and let me know what command I should but into the nrpe.cfg file for Nagios to be able to sudo to the correct user and run the script
Thanks
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: monitoring output from basj script
Did you write the script?
You might first want to try adjusting the script to remove all the sudo commands
If you still have problems you are going to need to adjust the sudoers file on the server which would be best to have a Unix/Linux person help you with if you have one on staff
You might first want to try adjusting the script to remove all the sudo commands
Code: Select all
output=$(/usr/bin/tail -n 1 /opt/NA/app_users/UDeployUser/lastbackups)
if [[ -z "$(/bin/find /opt/NA/app_users/UDeployUser/lastbackups -mtime -1)" ]] ; then
echo "CRITICAL - Backup too old $ouput"
exit 2
else
echo "OK - Backup is recent"
exit 0
fi