From 085ba7e17cda7a24dc081b86c7b5cc5c1b6764c6 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Mon, 7 Dec 2020 15:36:51 +0100 Subject: [PATCH] check_snmp_storage.pl: add support for allowing considering OK if no storage found matching given criteria by adding d/p/17_check_snmp_storage_okifempty from upstream --- .../patches/17_check_snmp_storage_okifempty | 61 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 62 insertions(+) create mode 100644 debian/patches/17_check_snmp_storage_okifempty diff --git a/debian/patches/17_check_snmp_storage_okifempty b/debian/patches/17_check_snmp_storage_okifempty new file mode 100644 index 0000000..8dffde8 --- /dev/null +++ b/debian/patches/17_check_snmp_storage_okifempty @@ -0,0 +1,61 @@ +From fd5ae19315a26530159f8ab221a190ac52de3195 Mon Sep 17 00:00:00 2001 +From: roa +Date: Mon, 9 Mar 2020 11:56:04 +0000 +Subject: [PATCH] check_snmp_storage.pl: add support for allowing considering + OK if no storage found matching given criteria + +--- + plugins/check_snmp_storage.pl | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/plugins/check_snmp_storage.pl b/plugins/check_snmp_storage.pl +index 3593f79..887800a 100755 +--- a/plugins/check_snmp_storage.pl ++++ b/plugins/check_snmp_storage.pl +@@ -73,6 +73,7 @@ + my $o_sum = undef; # add all storage before testing + my $o_index = undef; # Parse index instead of description + my $o_negate = undef; # Negate the regexp if set ++my $o_okifempty = undef; # Consider OK if no disks found + my $o_timeout = 5; # Default 5s Timeout + my $o_perf = undef; # Output performance data + my $o_short = undef; # Short output parameters +@@ -98,7 +99,7 @@ + + sub print_usage { + print +-"Usage: $Name [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -m [-q storagetype] -w -c [-t ] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-S 0|1[,1,]] [-o ] [-R <% reserved>]\n"; ++"Usage: $Name [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -m [-q storagetype] -w -c [-t ] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-O] [-S 0|1[,1,]] [-o ] [-R <% reserved>]\n"; + } + + sub round ($$) { +@@ -180,6 +181,8 @@ sub help { + -e, --exclude + Select all storages except the one(s) selected by -m + No action on storage type selection ++-O, --okifempty ++ Consider OK instead of UNKNOWN if no storage found with given criteria + -T, --type=TYPE + pl : calculate percent left + pu : calculate percent used (Default) +@@ -279,6 +282,8 @@ sub check_options { + 'index' => \$o_index, + 'e' => \$o_negate, + 'exclude' => \$o_negate, ++ 'O' => \$o_okifempty, ++ 'okifempty' => \$o_okifempty, + 'V' => \$o_version, + 'version' => \$o_version, + 'q:s' => \$o_storagetype, +@@ -590,7 +595,10 @@ sub check_options { + } + } + verb("storages selected : $num_int"); +-if ($num_int == 0) { print "Unknown storage : $o_descr : ERROR\n"; exit $ERRORS{"UNKNOWN"}; } ++if ($num_int == 0) { ++ if ($o_okifempty) { print "No storage found matching given criteria, but future new disks will be monitored\n"; exit $ERRORS{"OK"}; } ++ else { print "Unknown storage : $o_descr : ERROR\n"; exit $ERRORS{"UNKNOWN"}; } ++} + + my $result = undef; + diff --git a/debian/patches/series b/debian/patches/series index ad269ae..421df72 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,5 +5,6 @@ 14_check_snmp_int_ign 15_check_snmp_int_spaces 16_check_snmp_win_max_message_size +17_check_snmp_storage_okifempty 50_disable_epn 51_fix_privacy_doc