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
This commit is contained in:
		
							parent
							
								
									ef233ba6df
								
							
						
					
					
						commit
						085ba7e17c
					
				
					 2 changed files with 62 additions and 0 deletions
				
			
		
							
								
								
									
										61
									
								
								debian/patches/17_check_snmp_storage_okifempty
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								debian/patches/17_check_snmp_storage_okifempty
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,61 @@
 | 
			
		|||
From fd5ae19315a26530159f8ab221a190ac52de3195 Mon Sep 17 00:00:00 2001
 | 
			
		||||
From: roa <roa@eurotux.com>
 | 
			
		||||
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 <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-P <protocol>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-S 0|1[,1,<car>]] [-o <octet_length>] [-R <% reserved>]\n";
 | 
			
		||||
+"Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-P <protocol>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-O] [-S 0|1[,1,<car>]] [-o <octet_length>] [-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;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue