Adding d/p/10_check_snmp_storage_error_handling

This commit is contained in:
Jan Wagner 2019-01-23 20:09:54 +01:00
parent cb66729916
commit bcc13b46d0
2 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,42 @@
From e7472bfb2a39f3536350642b177e5f9e17c5c369 Mon Sep 17 00:00:00 2001
From: Louis Sautier <sautier.louis@gmail.com>
Date: Mon, 29 Jan 2018 09:17:25 +0100
Subject: [PATCH] check_snmp_storage: fix SNMP error handling, see #33
---
plugins/check_snmp_storage.pl | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/plugins/check_snmp_storage.pl b/plugins/check_snmp_storage.pl
index 2325acc..3593f79 100755
--- a/plugins/check_snmp_storage.pl
+++ b/plugins/check_snmp_storage.pl
@@ -598,6 +598,15 @@ sub check_options {
$result = $session->get_request(@oids);
} else {
$result = $session->get_request(Varbindlist => \@oids);
+}
+
+if (!defined($result)) {
+ printf("ERROR getting OIDs: %s.\n", $session->error);
+ $session->close;
+ exit $ERRORS{"UNKNOWN"};
+}
+
+if (version->parse(Net::SNMP->VERSION) >= 4) {
foreach my $key (sort keys %$result) {
# Fix for filesystems larger 2 TB. More than 2 TB will cause an error because
@@ -613,12 +622,6 @@ sub check_options {
}
}
-if (!defined($result)) {
- printf("ERROR: Size table :%s.\n", $session->error);
- $session->close;
- exit $ERRORS{"UNKNOWN"};
-}
-
$session->close;
# Only a few ms left...

View file

@ -1,2 +1,3 @@
10_check_snmp_storage_error_handling
50_disable_epn
51_fix_privacy_doc