Multiple Critical Conditions
Posted: Fri Apr 24, 2015 3:04 pm
I am looking to set a critical threshold based on two conditions. I know that by specifying multiple -c in the check, it does an OR. How do I set AND?
Support for Nagios products and services
https://support.nagios.com/forum/
Code: Select all
#!/bin/bash
nrpe="/usr/local/nagios/libexec/check_nrpe"
hostname="127.0.0.1"
check_one="$1"
check_two="$2"
$nrpe -H $hostname -c $check_one
return_one=$?
$nrpe -H $hostname -c $check_two
return_two=$?
output=3
if [ "$return_one" -ge 0 ] && [ "$return_two" -ge 0 ]; then
output=0
status="OK"
fi
if [ "$return_one" -ge 1 ] && [ "$return_two" -ge 1 ]; then
output=1
status="WARNING"
fi
if [ "$return_one" -eq 2 ] && [ "$return_two" -eq 2 ]; then
output=2
status="CRITICAL"
fi
echo $status
exit $outputCode: Select all
[jdalrymple@localhost libexec]$ ./wrapper.sh this_returns_CRITICAL this_returns_CRITICAL
CRITICAL
CRITICAL
CRITICAL
[jdalrymple@localhost libexec]$ ./wrapper.sh this_returns_CRITICAL this_returns_WARNING
CRITICAL
WARNING
WARNING
[jdalrymple@localhost libexec]$ ./wrapper.sh this_returns_CRITICAL this_returns_OK
CRITICAL
OK
OK