Page 2 of 5
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 9:09 am
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$
}
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 9:36 am
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?
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 10:04 am
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
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 10:06 am
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.
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 10:14 am
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.
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 3:11 pm
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?
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 3:21 pm
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.
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 3:28 pm
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?
Re: Custom SNMP check
Posted: Mon Jun 29, 2015 4:49 pm
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)
Re: Custom SNMP check
Posted: Tue Jun 30, 2015 7:34 am
by angus
Is this what you are looking for?