Need help with SNMP - everything is OK?
Need help with SNMP - everything is OK?
We are trying to use Nagios to monitor the power status of an Adtran MX2800. We have the MIBs installed and have found the correct OID and have the monitor set up. However, no matter what is indicated in the status information section (normal, warning, failed, etc.) the status is always OK and green. How do I configure Nagios to show a different status dependent on what the SNMP return is?
Re: Need help with SNMP - everything is OK?
Is the check returning a string or a numerical value?
Re: Need help with SNMP - everything is OK?
This is the result of a test:
COMMAND: /usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB
OUTPUT: SNMP OK - Power Supply Status normal(1) |
It seems that the actual data returned is "normal(1)". Other results include "error(2)", "onBackup(5)", and "powerFail(4)", among others. Our goal is to have anything which is not "normal(1)" to change the status to critical instead of OK
COMMAND: /usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB
OUTPUT: SNMP OK - Power Supply Status normal(1) |
It seems that the actual data returned is "normal(1)". Other results include "error(2)", "onBackup(5)", and "powerFail(4)", among others. Our goal is to have anything which is not "normal(1)" to change the status to critical instead of OK
Re: Need help with SNMP - everything is OK?
Add custom command that is as follows:
Code: Select all
COMMAND: /usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB | grep "normal(1)"Re: Need help with SNMP - everything is OK?
A test of that results in :
The status changes to warning (yellow) with the status information displayed as:COMMAND: /usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB |grep "normal(1)"
OUTPUT:
(No output on stdout) stderr
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Need help with SNMP - everything is OK?
Does the following work for you?
Code: Select all
/usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB -r 1 --invert-searchRe: Need help with SNMP - everything is OK?
The result from that one is:
It looks like it changes the status to critical but it appears that it will be critical for all results and not just the non-normal results.COMMAND: /usr/local/nagios/libexec/check_snmp -H spmux -o 1.3.6.1.4.1.664.2.198.1.8.1.3.1 -C public -P 1 -l "Power Supply Status" -m ADTRAN-MX2800-MIB -r 1 --invert-search
OUTPUT: SNMP CRITICAL - Power Supply Status *normal(1)* |
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Need help with SNMP - everything is OK?
Ooops, my logic was wrong.
Simply omit --invert-search and you should get CRITICAL for any non matching result (a result that doesn't include the integer 1)
See the behavior in my lab:
Simply omit --invert-search and you should get CRITICAL for any non matching result (a result that doesn't include the integer 1)
See the behavior in my lab:
Code: Select all
[jdalrymple@localhost libexec]$ ./check_snmp -H localhost -C public -o SNMPv2-MIB::sysORUpTime.6 -r 1
SNMP CRITICAL - *Timeticks: (2) 0:00:00.02* |
[jdalrymple@localhost libexec]$ ./check_snmp -H localhost -C public -o SNMPv2-MIB::sysORUpTime.6 -r 2
SNMP OK - Timeticks: (2) 0:00:00.02 |
[jdalrymple@localhost libexec]$ ./check_snmp -H localhost -C public -o SNMPv2-MIB::sysORUpTime.6 -r 2 --invert-search
SNMP CRITICAL - *Timeticks: (2) 0:00:00.02* |
[jdalrymple@localhost libexec]$ ./check_snmp -H localhost -C public -o SNMPv2-MIB::sysORUpTime.6 -r 1 --invert-search
SNMP OK - Timeticks: (2) 0:00:00.02 |Re: Need help with SNMP - everything is OK?
Thank you. I had not seen the full list of available arguments for check_snmp but I looked them up after seeing your suggestion.
I won't be able to try it until lunch time but this looks good. I'll update this afternoon.
I won't be able to try it until lunch time but this looks good. I'll update this afternoon.
Re: Need help with SNMP - everything is OK?
That did it! Thank you for your help!