mirror of
				https://github.com/centreon/centreon-plugins.git
				synced 2025-10-31 03:13:49 +01:00 
			
		
		
		
	enh(standard/snmp): storage mode - add --counters-overflow option (#3061)
This commit is contained in:
		
							parent
							
								
									041d9444ad
								
							
						
					
					
						commit
						353b1b45f7
					
				| @ -66,7 +66,7 @@ my %storage_types_manage = ( | |||||||
|     '.1.3.6.1.2.1.25.3.9.20' => 'hrFSDGCFS', |     '.1.3.6.1.2.1.25.3.9.20' => 'hrFSDGCFS', | ||||||
|     '.1.3.6.1.2.1.25.3.9.21' => 'hrFSBFS', |     '.1.3.6.1.2.1.25.3.9.21' => 'hrFSBFS', | ||||||
|     '.1.3.6.1.2.1.25.3.9.22' => 'hrFSFAT32', |     '.1.3.6.1.2.1.25.3.9.22' => 'hrFSFAT32', | ||||||
|     '.1.3.6.1.2.1.25.3.9.23' => 'hrFSLinuxExt2', |     '.1.3.6.1.2.1.25.3.9.23' => 'hrFSLinuxExt2' | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
| sub custom_usage_perfdata { | sub custom_usage_perfdata { | ||||||
| @ -158,7 +158,8 @@ sub custom_usage_calc { | |||||||
| sub custom_access_output { | sub custom_access_output { | ||||||
|     my ($self, %options) = @_; |     my ($self, %options) = @_; | ||||||
| 
 | 
 | ||||||
|     my $msg = sprintf("Access : %s",  |     my $msg = sprintf( | ||||||
|  |         'Access : %s',  | ||||||
|         $self->{result_values}->{access} == 1 ? 'readWrite' : 'readOnly' |         $self->{result_values}->{access} == 1 ? 'readWrite' : 'readOnly' | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -239,6 +240,7 @@ sub new { | |||||||
|         'filter-duplicate'        => { name => 'filter_duplicate' }, |         'filter-duplicate'        => { name => 'filter_duplicate' }, | ||||||
|         'filter-storage-type:s'   => { name => 'filter_storage_type', default => $self->default_storage_type() }, |         'filter-storage-type:s'   => { name => 'filter_storage_type', default => $self->default_storage_type() }, | ||||||
|         'add-access'              => { name => 'add_access' }, |         'add-access'              => { name => 'add_access' }, | ||||||
|  |         'counters-overflow'       => { name => 'counters_overflow' } | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     $self->{storage_id_selected} = []; |     $self->{storage_id_selected} = []; | ||||||
| @ -336,13 +338,19 @@ sub manage_selection { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         # in bytes hrStorageAllocationUnits |         # in bytes hrStorageAllocationUnits | ||||||
|         my $total_size = $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_}; |         my $size = $result->{$oid_hrStorageSize . '.' . $_}; | ||||||
|         if ($total_size <= 0) { |         my $used = $result->{$oid_hrStorageUsed . '.' . $_}; | ||||||
|  |         if (defined($self->{option_results}->{counters_overflow})) { | ||||||
|  |             $size += 2**32 if ($size <= 0); | ||||||
|  |             $used += 2**32 if ($used <= 0); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if ($size <= 0) { | ||||||
|             $self->{output}->output_add( |             $self->{output}->output_add( | ||||||
|                 long_msg => sprintf( |                 long_msg => sprintf( | ||||||
|                     "skipping storage '%s': total size is <= 0 (%s)",  |                     "skipping storage '%s': total size is <= 0 (%s) (try option --counters-overflow)",  | ||||||
|                     $name_storage, |                     $name_storage, | ||||||
|                     int($total_size) |                     $size | ||||||
|                 ), |                 ), | ||||||
|                 debug => 1 |                 debug => 1 | ||||||
|             ); |             ); | ||||||
| @ -353,8 +361,8 @@ sub manage_selection { | |||||||
|             my $duplicate = 0; |             my $duplicate = 0; | ||||||
|             foreach my $entry (values %{$self->{storage}}) { |             foreach my $entry (values %{$self->{storage}}) { | ||||||
|                 if (($entry->{allocation_units} == $result->{$oid_hrStorageAllocationUnits . '.' . $_}) && |                 if (($entry->{allocation_units} == $result->{$oid_hrStorageAllocationUnits . '.' . $_}) && | ||||||
|                     ($entry->{size} == $result->{$oid_hrStorageSize . "." . $_}) && |                     ($entry->{size} == $result->{$oid_hrStorageSize . '.' . $_}) && | ||||||
|                     ($entry->{used} == $result->{$oid_hrStorageUsed . "." . $_})) { |                     ($entry->{used} == $result->{$oid_hrStorageUsed . '.' . $_})) { | ||||||
|                     $duplicate = 1; |                     $duplicate = 1; | ||||||
|                     last; |                     last; | ||||||
|                 } |                 } | ||||||
| @ -365,9 +373,9 @@ sub manage_selection { | |||||||
|         $self->{storage}->{$_} = { |         $self->{storage}->{$_} = { | ||||||
|             display => $name_storage, |             display => $name_storage, | ||||||
|             allocation_units => $result->{$oid_hrStorageAllocationUnits . '.' . $_}, |             allocation_units => $result->{$oid_hrStorageAllocationUnits . '.' . $_}, | ||||||
|             size => $result->{$oid_hrStorageSize . '.' . $_}, |             size => $size, | ||||||
|             used => $result->{$oid_hrStorageUsed . '.' . $_}, |             used => $used, | ||||||
|             access => defined($access_result->{$_}) ? $access_result->{$_} : undef, |             access => defined($access_result->{$_}) ? $access_result->{$_} : undef | ||||||
|         }; |         }; | ||||||
|         $self->{global}->{count}++; |         $self->{global}->{count}++; | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user