Custom SNMP check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Custom SNMP check

Post by ssax »

Try this:

Check Command: check_snmp
$ARG1$ : -o .1.3.6.1.4.1.3530.8.7.145.120.30.1.6.1.0.1 -C community -P 2c

Here are the other options:

Code: Select all

check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]
[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]
[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]
[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]
[-A authpasswd] [-x privproto] [-X privpasswd]
Edit:

Here is the command definition so you can see you don't need to pass in the hostname/IP and all the other options should be in $ARG1$:

Code: Select all

define command {
       command_name                             check_snmp
       command_line                             $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
angus
Posts: 125
Joined: Thu May 28, 2015 8:17 am

Re: Custom SNMP check

Post by angus »

Awesome, thanks. I have the service running. My running state is "1". I want to set critical to "0". when i do that Nagios reports my state as critical. This is obviously due to 1 being greater the 0. is there a way i can set the critical to go off for any value other the 1?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Custom SNMP check

Post by ssax »

You can use the -s option:

$ARG1$ : -o .1.3.6.1.4.1.3530.8.7.145.120.30.1.6.1.0.1 -C community -P 2c -s 1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Custom SNMP check

Post by tgriep »

Here is a link that explains how thresholds work for the plugins in Nagios.
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

If you define your critical threshold like this -c 1:
Which means Critical if "stuff" is less than 1, this should work for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom SNMP check

Post by abrist »

You can force the thresholds to work in reverse with "<value>:". For example:

Code: Select all

[root@localhost libexec]# ./check_snmp -H <ip> -o ifAdminStatus.2 -C <community> -c 2:
SNMP CRITICAL - *1* | IF-MIB::ifAdminStatus.2=1;;0;
[root@localhost libexec]# ./check_snmp -H <ip> -o ifAdminStatus.2 -C  -c 1:
SNMP OK - 1 | IF-MIB::ifAdminStatus.2=1;;0;
So in your example, try:

Code: Select all

Check Command: check_snmp
$ARG1$ : -o .1.3.6.1.4.1.3530.8.7.145.120.30.1.6.1.0.1 -C community -P 2c -c 1:
This will be ok on 1, and critical on zero.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
angus
Posts: 125
Joined: Thu May 28, 2015 8:17 am

Re: Custom SNMP check

Post by angus »

That is very helpful, thank you.

I have another SNMP string i am pulling but the output is very odd. I would like the graph to report an integer and not the c value, by this i mean i would like to see "65" instead of "65c". Is that possible?
You do not have the required permissions to view the files attached to this post.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom SNMP check

Post by abrist »

That is actually working as expected as the "<value>c" is a counter. It does seem that it is graphing correctly, is that right?
You would have to create a wrapper script to remove the c, but that would actually be a bad idea as that is detected by the process perfdata scripts so that the perfdata is treated as a counter instead of a pure value.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
angus
Posts: 125
Joined: Thu May 28, 2015 8:17 am

Re: Custom SNMP check

Post by angus »

The <value>c doesn't bother be all that much but if you look at the graph and the gauge they do not match. the current value was 62c but the graph shows .012c. I would like the graph to show 62c.

Also if i set an alarm i would specify "-w 70c -c 95c" correct?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom SNMP check

Post by abrist »

You should not have to us the "c" suffix at all for the thresholds, just "-w 70 -c 95" should suffice.
The issues with the gauge are quite odd. Can you post the pure output (including performance data) from the check? (running a test check from the CCM should output the entire string)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
angus
Posts: 125
Joined: Thu May 28, 2015 8:17 am

Re: Custom SNMP check

Post by angus »

Is this what you are looking for?
You do not have the required permissions to view the files attached to this post.
Locked