File: 24_check_snmp_int_use_ifname

package info (click to toggle)
nagios-snmp-plugins 2.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,008 kB
  • ctags: 381
  • sloc: perl: 7,178; sh: 309; makefile: 50
file content (63 lines) | stat: -rw-r--r-- 2,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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)) {