monitoring output from basj script
Posted: Mon Sep 09, 2019 9:27 am
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
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