Page 1 of 1

Multiple Critical Conditions

Posted: Fri Apr 24, 2015 3:04 pm
by OptimusB
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?

Re: Multiple Critical Conditions

Posted: Fri Apr 24, 2015 5:38 pm
by jdalrymple
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.

Re: Multiple Critical Conditions

Posted: Tue Apr 28, 2015 11:22 am
by OptimusB
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.

Re: Multiple Critical Conditions

Posted: Tue Apr 28, 2015 1:57 pm
by jdalrymple
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:

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 $output
The results:

Code: 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