Multiple Critical Conditions
Multiple Critical Conditions
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?
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Multiple Critical Conditions
It absolutely depends on how the plugin is written. Well behaved plugins should conform to the guidelines however even in the guidelines there is no spec for multiple thresholds.
Which plugin specifically are you referring to? If you can tell us maybe we can dig into the code and try to understand the behavior for you.
Which plugin specifically are you referring to? If you can tell us maybe we can dig into the code and try to understand the behavior for you.
Re: Multiple Critical Conditions
I am looking to do this with check_wmi_plus. I was looking at the checkprint mode which can look at multiple conditions. I wanted to see if there's the ability to do AND instead of OR.
Thanks.
Thanks.
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Multiple Critical Conditions
Since I can't make the checkprint mode work for me at all on my test machine (I always get the "must provide valid mode/submode error") I suggest an alternative approach than to use check_wmi_plus's builtin logic. Creating a wrapper script is super trivial:
wrapper.sh:
The results:
wrapper.sh:
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