Page 1 of 1

Setting multiple thresholds

Posted: Tue Feb 27, 2018 8:16 am
by mksmr
Good afternoon everybody,

I wondered if the following was possible:

HP hardware is returning the following values when checked with check_snmp:

1 - unknown/other
2 - ok
3 - warning
4 - critical

I'd want to set my warning level so that a return value of 3 or below 2 results in "warning" and 4 results in "critical". The obvious solution is to append the "-s 2" directive to the check_snmp command, but this will report any status but 2 as "critical". I'd want only 4 as "critical" and anything else (without 2, obviously) as "warning". Is there a way to achieve this?

TIA
Matthias

Re: Setting multiple thresholds

Posted: Tue Feb 27, 2018 2:53 pm
by mcapra
Assuming the OID's value is correctly typed as a numeric value and not as something like a string, yeah you can do that. From the manpage:

Code: Select all

     -w, --warning=THRESHOLD(s)
        Warning threshold range(s)
     -c, --critical=THRESHOLD(s)
        Critical threshold range(s)
...
- When checking multiple OIDs, separate ranges by commas like '-w 1:10,1:,:20'
Here's how the Nagios Plugin Development Guidelines says you should handle ranges in your plugins:
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
mksmr wrote:I'd want to set my warning level so that a return value of 3 or below 2 results in "warning" and 4 results in "critical".
Following the guidelines, this should work (again, assuming a numeric data type for the OIDs value):
-w @3: -c 4

If it's a String value, you probably need to leverage regular expressions to get the desired effect.

Re: Setting multiple thresholds

Posted: Wed Feb 28, 2018 5:27 pm
by kyang
Thanks for the help @mcapra!