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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
From ed1da1396f3ca3337a4ebe3f0cf610a30e6c5775 Mon Sep 17 00:00:00 2001
From: Jochen Friedrich <j.friedrich@nwe.de>
Date: Wed, 14 Mar 2018 15:31:00 +0100
Subject: [PATCH] Workaround for buggy SNMP agents not removing deleted
interfaces.
If exact match is requested, only use the interface with the highest index.
Some buggy SNMP agents forget to delete interfaces which are gone (like ppp
or tunnel interfaces).
---
plugins/check_snmp_int.pl | 57 ++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/plugins/check_snmp_int.pl b/plugins/check_snmp_int.pl
index 9d4a2a5..e938131 100755
--- a/plugins/check_snmp_int.pl
+++ b/plugins/check_snmp_int.pl
@@ -632,35 +632,38 @@ sub check_options {
# get the index number of the interface
my @oid_list = split(/\./, $key);
- $tindex[$num_int] = pop(@oid_list);
-
- # get the full description
- $descr[$num_int] = $$resultat{$key};
-
- # Get rid of special caracters (specially for Windows)
- $descr[$num_int] =~ s/[[:cntrl:]]//g;
-
- # put the admin or oper oid in an array
- $oids[$num_int]
- = defined($o_admin)
- ? $admin_table . $tindex[$num_int]
- : $oper_table . $tindex[$num_int];
-
- # Put the performance oid
- if (defined($o_perf) || defined($o_checkperf)) {
- $oid_perf_inoct[$num_int] = $in_octet_table . $tindex[$num_int];
- $oid_perf_outoct[$num_int] = $out_octet_table . $tindex[$num_int];
- $oid_speed[$num_int] = $speed_table . $tindex[$num_int];
- $oid_speed_high[$num_int] = $speed_table_64 . $tindex[$num_int];
- if (defined($o_ext_checkperf) || defined($o_perfe)) {
- $oid_perf_indisc[$num_int] = $in_discard_table . $tindex[$num_int];
- $oid_perf_outdisc[$num_int] = $out_discard_table . $tindex[$num_int];
- $oid_perf_inerr[$num_int] = $in_error_table . $tindex[$num_int];
- $oid_perf_outerr[$num_int] = $out_error_table . $tindex[$num_int];
+ my $int_index = pop(@oid_list);
+ if (defined($o_noreg) && ($num_int > 0)) {
+ if ($tindex[$num_int-1] < $int_index) {
+ $num_int = 0;
}
}
- verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
- $num_int++;
+ if (!defined($o_noreg) || ($num_int == 0)) {
+ $tindex[$num_int] = $int_index;
+ # get the full description
+ $descr[$num_int]=$$resultat{$key};
+ # Get rid of special caracters (specially for Windows)
+ $descr[$num_int] =~ s/[[:cntrl:]]//g;
+ # put the admin or oper oid in an array
+ $oids[$num_int]= defined ($o_admin) ? $admin_table . $tindex[$num_int]
+ : $oper_table . $tindex[$num_int];
+
+ # Put the performance oid
+ if (defined($o_perf) || defined($o_checkperf)) {
+ $oid_perf_inoct[$num_int]= $in_octet_table . $tindex[$num_int];
+ $oid_perf_outoct[$num_int]= $out_octet_table . $tindex[$num_int];
+ $oid_speed[$num_int]=$speed_table . $tindex[$num_int];
+ $oid_speed_high[$num_int]=$speed_table_64 . $tindex[$num_int];
+ if (defined($o_ext_checkperf) || defined($o_perfe)) {
+ $oid_perf_indisc[$num_int]= $in_discard_table . $tindex[$num_int];
+ $oid_perf_outdisc[$num_int]= $out_discard_table . $tindex[$num_int];
+ $oid_perf_inerr[$num_int]= $in_error_table . $tindex[$num_int];
+ $oid_perf_outerr[$num_int]= $out_error_table . $tindex[$num_int];
+ }
+ }
+ verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
+ $num_int++;
+ }
}
}
|