| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::devices::camera::avigilon::snmp::mode::storage; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); |
| 25 |
use centreon::plugins::misc qw(is_empty); |
| 26 |
|
| 27 |
use strict; |
| 28 |
use warnings; |
| 29 |
|
| 30 |
sub set_counters { |
| 31 |
my ($self, %options) = @_; |
| 32 |
|
| 33 |
$self->{maps_counters_type} = [ |
| 34 |
{ name => 'storage', type => 0 } |
| 35 |
]; |
| 36 |
|
| 37 |
$self->{maps_counters}->{storage} = [ |
| 38 |
{ label => 'status', |
| 39 |
type => 2, |
| 40 |
unknown_default => '%{storage_state} =~ /Unknown/i', |
| 41 |
warning_default => '%{storage_state} =~ /insufficientMediaCapacity/i || %{storage_state} =~ /insufficientMediaSpeed/i', |
| 42 |
critical_default => '%{storage_state} =~ /mediaNotPresent/i || %{storage_state} =~ /error/i', |
| 43 |
set => { |
| 44 |
key_values => [{ name => 'storage_state' }], |
| 45 |
output_template => 'state of the SD card: %s', |
| 46 |
closure_custom_perfdata => sub { return 0; }, |
| 47 |
closure_custom_threshold_check => \&catalog_status_threshold_ng |
| 48 |
} |
| 49 |
} |
| 50 |
]; |
| 51 |
} |
| 52 |
|
| 53 |
sub new { |
| 54 |
my ($class, %options) = @_; |
| 55 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 56 |
bless $self, $class; |
| 57 |
|
| 58 |
$options{options}->add_options(arguments => { |
| 59 |
}); |
| 60 |
|
| 61 |
return $self; |
| 62 |
} |
| 63 |
|
| 64 |
sub manage_selection { |
| 65 |
my ($self, %options) = @_; |
| 66 |
|
| 67 |
my $storage_state_mapping = { |
| 68 |
1 => 'mediaNotPresent', |
| 69 |
2 => 'mediaDetected', |
| 70 |
3 => 'existingDataOnMediaDetected', |
| 71 |
4 => 'mediaFormatting', |
| 72 |
5 => 'scanningForRecordings', |
| 73 |
6 => 'readOnly', |
| 74 |
7 => 'readyToRecord', |
| 75 |
8 => 'recording', |
| 76 |
9 => 'errorFormatting', |
| 77 |
10 => 'errorWriting', |
| 78 |
11 => 'insufficientMediaCapacity', |
| 79 |
12 => 'insufficientMediaSpeed', |
| 80 |
13 => 'error' |
| 81 |
}; |
| 82 |
|
| 83 |
my $oid_storage_state = '.1.3.6.1.4.1.46202.1.1.1.5.0'; #storageState |
| 84 |
my $snmp_result = $options{snmp}->get_leef( |
| 85 |
oids => [$oid_storage_state], |
| 86 |
nothing_quit => 1 |
| 87 |
); |
| 88 |
|
| 89 |
if(centreon::plugins::misc::is_empty($storage_state_mapping->{$snmp_result->{$oid_storage_state}})==0){ |
| 90 |
$self->{storage} = { |
| 91 |
storage_state => $storage_state_mapping->{$snmp_result->{$oid_storage_state}} |
| 92 |
}; |
| 93 |
# If state is not in the mapping, return unkown |
| 94 |
}else{ |
| 95 |
$self->{storage} = { |
| 96 |
storage_state => "Unknown" |
| 97 |
}; |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
1; |
| 102 |
|
| 103 |
__END__ |
| 104 |
|
| 105 |
=head1 MODE |
| 106 |
|
| 107 |
Check storage state of the SD card. |
| 108 |
|
| 109 |
=over 8 |
| 110 |
|
| 111 |
=item B<--unknown-status> |
| 112 |
|
| 113 |
Define the conditions to match to return a unknown status (default: "%{storage_state} =~ /Unknown/i"). |
| 114 |
The condition can be written using the following macros: %{storage_state}. |
| 115 |
|
| 116 |
=item B<--warning-status> |
| 117 |
|
| 118 |
Define the conditions to match to return a warning status (default: "%{storage_state} =~ /insufficientMediaCapacity/i || %{storage_state} =~ /insufficientMediaSpeed/i"). |
| 119 |
The condition can be written using the following macros: %{storage_state}. |
| 120 |
|
| 121 |
=item B<--critical-status> |
| 122 |
|
| 123 |
Define the conditions to match to return a critical status (default: "%{storage_state} =~ /mediaNotPresent/i || %{storage_state} =~ /error/i"). |
| 124 |
The condition can be written using the following macros: %{storage_state}. |
| 125 |
|
| 126 |
=back |
| 127 |
|
| 128 |
=cut |