check_snmp_int: Add patches/24_check_snmp_int_use_ifname (Closes: #812837)

This commit is contained in:
Jan Wagner 2016-01-27 14:30:34 +01:00
parent 6cbfcfac62
commit c5e9ec0af1
2 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,63 @@
From e684d56ab83e86d037403478c7245087e17f63b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Lapie?= <darksoul@darkbsd.org>
Date: Wed, 27 Jan 2016 21:47:01 +0900
Subject: [PATCH] Add the -N/--use-ifname option to switch name lookup from
ifDescr to ifName
---
check_snmp_int.pl | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/check_snmp_int.pl b/check_snmp_int.pl
index 4847fd2..a92d6d1 100755
--- a/check_snmp_int.pl
+++ b/check_snmp_int.pl
@@ -29,6 +29,7 @@
my $inter_table= '.1.3.6.1.2.1.2.2.1';
my $index_table = '1.3.6.1.2.1.2.2.1.1';
my $descr_table = '1.3.6.1.2.1.2.2.1.2';
+my $name_table = '1.3.6.1.2.1.31.1.1.1.1';
my $oper_table = '1.3.6.1.2.1.2.2.1.8.';
my $admin_table = '1.3.6.1.2.1.2.2.1.7.';
my $speed_table = '1.3.6.1.2.1.2.2.1.5.';
@@ -79,6 +80,7 @@
my $o_meg= undef; # output in MBytes or Mbits (-M)
my $o_gig= undef; # output in GBytes or Gbits (-G)
my $o_prct= undef; # output in % of max speed (-u)
+my $o_use_ifname= undef; # use IF-MIB::ifName instead of IF-MIB::ifDescr
my $o_timeout= undef; # Timeout (Default 5)
# SNMP Message size parameter (Makina Corpus contrib)
@@ -188,6 +190,8 @@ sub help {
Test it before, because there are known bugs (ex : trailling /)
-r, --noregexp
Do not use regexp to match NAME in description OID
+-N, --use-ifname
+ Use IF-MIB::ifName as source for NIC name instead of IF-MIB::ifDescr
-i, --inverse
Make critical when up
-a, --admin
@@ -255,6 +259,7 @@ sub check_options {
'H:s' => \$o_host, 'hostname:s' => \$o_host,
'p:i' => \$o_port, 'port:i' => \$o_port,
'n:s' => \$o_descr, 'name:s' => \$o_descr,
+ 'N' => \$o_use_ifname, 'use-ifname' => \$o_use_ifname,
'C:s' => \$o_community, 'community:s' => \$o_community,
'2' => \$o_version2, 'v2c' => \$o_version2,
'l:s' => \$o_login, 'login:s' => \$o_login,
@@ -444,9 +449,13 @@ sub check_options {
verb(" new max octets:: $oct_test");
}
-# Get desctiption table
+# Get description table
+my $query_table = $descr_table;
+if (defined($o_use_ifname)) {
+ $query_table = $name_table;
+}
my $resultat = $session->get_table(
- Baseoid => $descr_table
+ Baseoid => $query_table
);
if (!defined($resultat)) {

View file

@ -9,5 +9,6 @@
21_check_snmp_load_abstract_snmp_version_check
22_remove_utils_pm
23_check_snmp_load_drop_debugging
24_check_snmp_int_use_ifname
50_disable_epn
51_fix_privacy_doc