| 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::server::hp::proliant::snmp::mode::components::fcaexternalctl; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_fcaexternalctl_status = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'ok', |
| 29 |
3 => 'failed', |
| 30 |
4 => 'offline', |
| 31 |
5 => 'redundantPathOffline', |
| 32 |
6 => 'notConnected', |
| 33 |
); |
| 34 |
|
| 35 |
my %map_fcaexternalctl_condition = ( |
| 36 |
1 => 'other', |
| 37 |
2 => 'ok', |
| 38 |
3 => 'degraded', |
| 39 |
4 => 'failed', |
| 40 |
); |
| 41 |
|
| 42 |
my %model_map = ( |
| 43 |
1 => 'other', |
| 44 |
2 => 'fibreArray', |
| 45 |
3 => 'msa1000', |
| 46 |
4 => 'smartArrayClusterStorage', |
| 47 |
5 => 'hsg80', |
| 48 |
6 => 'hsv110', |
| 49 |
7 => 'msa500G2', |
| 50 |
8 => 'msa20', |
| 51 |
9 => 'msa1510i', |
| 52 |
); |
| 53 |
|
| 54 |
my %map_role = ( |
| 55 |
1 => 'other', |
| 56 |
2 => 'notDuplexed', |
| 57 |
3 => 'active', |
| 58 |
4 => 'backup', |
| 59 |
); |
| 60 |
|
| 61 |
# In 'CPQFCA-MIB.mib' |
| 62 |
my $mapping = { |
| 63 |
cpqFcaCntlrModel => { oid => '.1.3.6.1.4.1.232.16.2.2.1.1.3', map => \%model_map }, |
| 64 |
cpqFcaCntlrStatus => { oid => '.1.3.6.1.4.1.232.16.2.2.1.1.5', map => \%map_fcaexternalctl_status }, |
| 65 |
cpqFcaCntlrCondition => { oid => '.1.3.6.1.4.1.232.16.2.2.1.1.6', map => \%map_fcaexternalctl_condition }, |
| 66 |
}; |
| 67 |
my $mapping2 = { |
| 68 |
cpqFcaCntlrCurrentRole => { oid => '.1.3.6.1.4.1.232.16.2.2.1.1.10', map => \%map_role }, |
| 69 |
}; |
| 70 |
my $oid_cpqFcaCntlrEntry = '.1.3.6.1.4.1.232.16.2.2.1.1'; |
| 71 |
my $oid_cpqFcaCntlrCurrentRole = '.1.3.6.1.4.1.232.16.2.2.1.1.10'; |
| 72 |
|
| 73 |
sub load { |
| 74 |
my ($self) = @_; |
| 75 |
|
| 76 |
push @{$self->{request}}, { oid => $oid_cpqFcaCntlrEntry, start => $mapping->{cpqFcaCntlrModel}->{oid}, end => $mapping->{cpqFcaCntlrCondition}->{oid} }, |
| 77 |
{ oid => $oid_cpqFcaCntlrCurrentRole }; |
| 78 |
} |
| 79 |
|
| 80 |
sub check { |
| 81 |
my ($self) = @_; |
| 82 |
|
| 83 |
$self->{output}->output_add(long_msg => "Checking fca external controller"); |
| 84 |
$self->{components}->{fcaexternalctl} = {name => 'fca external controllers', total => 0, skip => 0}; |
| 85 |
return if ($self->check_filter(section => 'fcaexternalctl')); |
| 86 |
|
| 87 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqFcaCntlrEntry}})) { |
| 88 |
next if ($oid !~ /^$mapping->{cpqFcaCntlrCondition}->{oid}\.(.*)$/); |
| 89 |
my $instance = $1; |
| 90 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqFcaCntlrEntry}, instance => $instance); |
| 91 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqFcaCntlrCurrentRole}, instance => $instance); |
| 92 |
|
| 93 |
next if ($self->check_filter(section => 'fcaexternalctl', instance => $instance)); |
| 94 |
$self->{components}->{fcaexternalctl}->{total}++; |
| 95 |
|
| 96 |
$self->{output}->output_add(long_msg => sprintf("fca external controller '%s' [model: %s, status: %s, role: %s] condition is %s.", |
| 97 |
$instance, |
| 98 |
$result->{cpqFcaCntlrModel}, $result->{cpqFcaCntlrStatus}, $result2->{cpqFcaCntlrCurrentRole}, |
| 99 |
$result->{cpqFcaCntlrCondition})); |
| 100 |
my $exit = $self->get_severity(label => 'default', section => 'fcaexternalctl', value => $result->{cpqFcaCntlrCondition}); |
| 101 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 102 |
$self->{output}->output_add(severity => $exit, |
| 103 |
short_msg => sprintf("fca external controller '%s' is %s", |
| 104 |
$instance, $result->{cpqFcaCntlrCondition})); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
1; |