Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_snmpv2.pl

Rating
3 votes
Favoured:
1
Current Version
1.7.0
Last Release Date
2012-01-13
Compatible With
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI
License
GPL
Hits
151689
Files:
FileDescription
check_snmpv2.plcheck_snmpv2.pl
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Script is used to check values of snmp enabled devices, such as Brocade switches, IBM Blade Chassis, Cisco devices...etc.

I added option for port. Added output to the first line if there is a critical or warning and a counter for number of checks OK.
USAGE: check_snmp.pl -H hostname -C community -p port -V version -t Title -O label:oid:warn:crit:[(l)less than | (g)greater than]:[(a)text|(n)number

You can enter multiple oid's, but the format MUST be ( label:oid:warn:crit:g:n,label:oid:warn:crit:l:a,... ),comma seperated.

Example (IBM Blade Chassis Voltages):

check_snmp.pl -H testbc -C public -p 161 -V 1 -t TESTBC_volt -O plus5:.1.3.6.1.4.1.2.3.51.2.2.2.1.1.0:4:3:l:n,plus3.3:.1.3.6.1.4.1.2.3.51.2.2.2.1.2.0:3:2.6:l:n,plus12:.1.3.6.1.4.1.2.3.51.2.2.2.1.3.0:11:10.5:l:n,minus5:.1.3.6.1.4.1.2.3.51.2.2.2.1.5.0:-4:-3.7:g:n,plus2.5:.1.3.6.1.4.1.2.3.51.2.2.2.1.6.0:2.2:2:l:n,plus1.8:.1.3.6.1.4.1.2.3.51.2.2.2.1.8.0:1.5:1.2:l:n

TESTBC_volt Status
OK: minus5 = -4.93
OK: plus2.5 = 2.48
OK: plus1.8 = 1.76
OK: plus3.3 = 3.26
OK: plus5 = 4.84
OK: plus12 = 11.78 | minus5=-4.93;-4;-3.7;0; plus2.5=2.48;2.2;2;0; plus1.8=1.76;1.5;1.2;0; plus3.3=3.26;3;2.6;0; plus5=4.84;4;3;0; plus12=11.78;11;10.5;0;

Example (Text Based Check value):
check_snmp.pl -H intbc -C public -p 161 -V 1 -t TESTBC_DIMM11 -O DIMM:.1.3.6.1.4.1.2.3.51.2.2.8.2.2.1.4.112:DIMM:dimm:x:a

TESTBC_DIMM11 Status
CRITICAL: DIMM = "DIMM 11" |

Nagios Command Definition:
define command{
command_name check_snmpv2
command_line $USER1$/check_snmp.pl -H $HOSTNAME$ -C $ARG1$ -p 161 -V $ARG2$ -t $ARG3$ -O $ARG4$
}

Reviews (3)
I had to modify the operators at lines 71,77,89 and 95 because they were "greater or equal" and "less or equal" instead of simply ">" or "Something I missed was the possibility to use directly textual MIB instead of the numeric OID, I saw that by using NetSNMP::OID it should be possible but did not have the time to try.
byrafamiga, December 23, 2012
I've patched the plugin to work with pragma "use strict" which apparently my Nagios3 uses...

Here's the patch:

http://orfika.net/src/check_snmpv2.pl.patch
bywillix, January 9, 2012
0 of 1 people found this review helpful
I don't want to discourage you (and starting like this is a good way to get some practice writing nagios plugins) but why are you writing this? Your script is not really a perl plugin because it relies on retrieving SNMP with external command. As such its just a wrapper and we already have check_snmp included with nagios plugin, written purely in C, and that can retrieve data from multiple SNMP OIDs and compare values. There is also at least one other alternative check_snmp (which is faster but does not work with SNMP v3), just look around exchange.

And if you want temperature I recommend you just download check_snmp_temperature.pl. Take a look at how its code too to learn how to write nagios plugins in Perl that retrieve data by SNMP. Then consider what is needed for your setup and write a new perl plugin (if it does not already exist) that you'd be proud of.
Owner's reply

Yeah, I've been writing plugins for nagios/netsaint for over a decade now.

There are lots of plugin scripts out there that are wrappers. And most scripts that utilize protocols, need to wrap themselves around libraries.

The check_snmp plugin does not take into consideration the output a device will generate. It is not that good, but a good start for most people.

I have seen lots of scripts which give you this output, or that output, but never one I can ask for whatever output I am looking for. So I wrote script that is easy enough to do just that. I can use this script to check every OID on any any device, and out put the data so it is useful for performance data or not.

Yes, I am proud of all of my code. Because I wrote it, and it works, and it is simple to understand and expand upon.