Here is a patch for a -N/--use-ifname option that will switch from IF-MIB::ifDescr to IF-MIB::ifName when looking up the interface's name.
This would enable users of nagios-snmp-plugins to tune whether they want to match interfaces based on the description, or on the name. -- ラピー ステファン Lapie Stephane 株式会社朝日ネット システム第1部 〒104-0061 東京都中央区銀座4-12-15 歌舞伎座タワー21F TEL : 03-3541-9590(代表) 03-3541-9591(直通) FAX : 03-3541-5633 E-MAIL: stephane.la...@asahinet.com
--- /tmp/check_snmp_int.pl 2016-01-27 11:24:26.144765849 +0900 +++ /tmp/check_snmp_int.pl.new 2016-01-27 11:47:40.904312037 +0900 @@ -31,6 +31,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.'; @@ -81,6 +82,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) @@ -190,6 +192,8 @@ 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 @@ -257,6 +261,7 @@ '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, @@ -446,9 +451,13 @@ 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)) {