Skip to content

Commit

Permalink
Merge pull request #14 from darksoul42/master
Browse files Browse the repository at this point in the history
Add -N/--use-ifname option to switch name lookup from ifDescr to ifName
  • Loading branch information
dnsmichi committed Jan 27, 2016
2 parents ea6c07e + e684d56 commit 7cb6b25
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/check_snmp_int.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 7cb6b25

Please sign in to comment.