Setting multiple thresholds

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mksmr
Posts: 55
Joined: Thu Sep 22, 2016 7:17 am

Setting multiple thresholds

Post 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
Hulluna humpasta taas
Minä olen hulluna humpasta taas
Minen toivu koskaan, luotan voimaan votkan
Hulluna humpasta taas
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Setting multiple thresholds

Post 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.
Former Nagios employee
https://www.mcapra.com/
kyang

Re: Setting multiple thresholds

Post by kyang »

Thanks for the help @mcapra!
Locked