| 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 storage::hitachi::standard::snmp::mode::components::component; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_status = ( |
| 27 |
0 => 'ok', |
| 28 |
1 => 'abnormal', |
| 29 |
); |
| 30 |
my %mapping_type = ( |
| 31 |
0 => 'drive', |
| 32 |
1 => 'spare drive', |
| 33 |
2 => 'data drive', |
| 34 |
3 => 'ENC', |
| 35 |
5 => 'notUsed', |
| 36 |
6 => 'warning', |
| 37 |
7 => 'Other controller', |
| 38 |
8 => 'UPS', |
| 39 |
9 => 'loop', |
| 40 |
10 => 'path', |
| 41 |
11 => 'NAS Server', |
| 42 |
12 => 'NAS Path', |
| 43 |
13 => 'NAS UPS', |
| 44 |
14 => 'notUsed', |
| 45 |
15 => 'notUsed', |
| 46 |
16 => 'battery', |
| 47 |
17 => 'power supply', |
| 48 |
18 => 'AC', |
| 49 |
19 => 'BK', |
| 50 |
20 => 'fan', |
| 51 |
21 => 'notUsed', |
| 52 |
22 => 'notUsed', |
| 53 |
23 => 'notUsed', |
| 54 |
24 => 'cache memory', |
| 55 |
25 => 'SATA spare disk', |
| 56 |
26 => 'SATA data drive', |
| 57 |
27 => 'SENC status', |
| 58 |
28 => 'HostConnector', |
| 59 |
29 => 'notUsed', |
| 60 |
30 => 'notUsed', |
| 61 |
31 => 'notUsed', |
| 62 |
); |
| 63 |
|
| 64 |
my $oid_dfRegressionStatus = '.1.3.6.1.4.1.116.5.11.1.2.2.1'; |
| 65 |
|
| 66 |
sub load { |
| 67 |
my ($self) = @_; |
| 68 |
|
| 69 |
push @{$self->{request}}, { oid => $oid_dfRegressionStatus }; |
| 70 |
} |
| 71 |
|
| 72 |
sub check { |
| 73 |
my ($self) = @_; |
| 74 |
|
| 75 |
$self->{output}->output_add(long_msg => "Checking components"); |
| 76 |
$self->{components}->{component} = {name => 'components', total => 0, skip => 0}; |
| 77 |
return if ($self->check_filter(section => 'component')); |
| 78 |
|
| 79 |
return if (!defined($self->{results}->{$oid_dfRegressionStatus}->{$oid_dfRegressionStatus . '.0'})); |
| 80 |
|
| 81 |
foreach my $bit_num (sort keys %mapping_type) { |
| 82 |
my $bit_indicate = int($self->{results}->{$oid_dfRegressionStatus}->{$oid_dfRegressionStatus . '.0'}) & (1 << int($bit_num)); |
| 83 |
$bit_indicate = 1 if ($bit_indicate > 0); |
| 84 |
my $status = $map_status{$bit_indicate}; |
| 85 |
next if ($self->check_filter(section => 'component', instance => $mapping_type{$bit_num})); |
| 86 |
$self->{components}->{component}->{total}++; |
| 87 |
|
| 88 |
$self->{output}->output_add(long_msg => sprintf("component '%s' status is '%s' [instance: %s].", |
| 89 |
$mapping_type{$bit_num}, $status, |
| 90 |
$mapping_type{$bit_num} |
| 91 |
)); |
| 92 |
my $exit = $self->get_severity(section => 'component', instance => $mapping_type{$bit_num}, value => $status); |
| 93 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 94 |
$self->{output}->output_add(severity => $exit, |
| 95 |
short_msg => sprintf("Component '%s' status is '%s'", |
| 96 |
$mapping_type{$bit_num}, $status)); |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
1; |