check_snmp set range for warning and critical



I am trying to setup a range of values for a critical/warning levels for a check_snmp script.

This is from the config script …

# check temperature sensor define command{ command_name check_temp_probe command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C public -o . -w $ARG1$ -c $ARG2$ -l "Temperature" -u "C" }

and this is the output

[root@intranet ~]# /usr/local/nagios/libexec/check_snmp -H -C public -o . SNMP OK - "24.5" | iso."24.5"

My first question is, is the cfg above look ok?
I am trying to figure out the best way of implementing this in the main.cfg file.

This is a temperature monitor in my server closet.
It returns a real number in degrees Celsius.

I think for warning it should be: 27 >= x < 30
And for critical it should be at: x >= 30
So the okay values should be: x < 27

How can I implement this, I am not good at using the ranges for W and C on the above command.

Any advise is appreciated.

Thank you,



yeah it’s a bit ugly…

[blockquote]- Ranges are inclusive and are indicated with colons. When specified as
’min:max’ a STATE_OK will be returned if the result is within the indicated
range or is equal to the upper or lower bound. A non-OK state will be
returned if the result is outside the specified range.

  • If specified in the order ‘max:min’ a non-OK state will be returned if the
    result is within the (inclusive) range.
  • Upper or lower bounds may be omitted to skip checking the respective limit.
  • Bare integers are interpreted as upper limits.
  • When checking multiple OIDs, separate ranges by commas like ‘-w 1:10,1:,:20’[/blockquote]
    I think you should be able to make use the of “max:min” and “bare integer interpreted as upper limit” notes and use

-w 29:27 -c :30
… that should “WARNING” between 27 and 29 (inclusive), and “CRITICAL” at 30 and above, else be “OK”, but have a play with the ranges and test from the CLI to ensure this behaves as you expect (i.e. if your current temp is 24 drop the -w arg to 29:23 and check it does WARNING alert, then make it something like -w 22:10 and -c :23 and confirm it CRITICAL alerts…
As far as your command definition, it looks good. You should be able to implement it with a check command looking like

where 29:27 translates to $ARG1$ and :30 to $ARG2$




great thanks so much, i think this will do it!