| 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::scsictl; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use centreon::plugins::misc; |
| 26 |
|
| 27 |
my %map_controller_status = ( |
| 28 |
1 => 'other', |
| 29 |
2 => 'ok', |
| 30 |
3 => 'failed', |
| 31 |
); |
| 32 |
|
| 33 |
my %map_controller_condition = ( |
| 34 |
1 => 'other', |
| 35 |
2 => 'ok', |
| 36 |
3 => 'degraded', |
| 37 |
4 => 'failed', |
| 38 |
); |
| 39 |
|
| 40 |
# In 'CPQSCSI-MIB.mib' |
| 41 |
my $mapping = { |
| 42 |
cpqScsiCntlrSlot => { oid => '.1.3.6.1.4.1.232.5.2.2.1.1.6' }, |
| 43 |
cpqScsiCntlrStatus => { oid => '.1.3.6.1.4.1.232.5.2.2.1.1.7', map => \%map_controller_status }, |
| 44 |
}; |
| 45 |
my $mapping2 = { |
| 46 |
cpqScsiCntlrCondition => { oid => '.1.3.6.1.4.1.232.5.2.2.1.1.12', map => \%map_controller_condition }, |
| 47 |
}; |
| 48 |
my $oid_cpqScsiCntlrEntry = '.1.3.6.1.4.1.232.5.2.2.1.1'; |
| 49 |
my $oid_cpqScsiCntlrCondition = '.1.3.6.1.4.1.232.5.2.2.1.1.12'; |
| 50 |
|
| 51 |
sub load { |
| 52 |
my ($self) = @_; |
| 53 |
|
| 54 |
push @{$self->{request}}, { oid => $oid_cpqScsiCntlrEntry, start => $mapping->{cpqScsiCntlrSlot}->{oid}, end => $mapping->{cpqScsiCntlrStatus}->{oid} }, |
| 55 |
{ oid => $oid_cpqScsiCntlrCondition }; |
| 56 |
} |
| 57 |
|
| 58 |
sub check { |
| 59 |
my ($self) = @_; |
| 60 |
|
| 61 |
$self->{output}->output_add(long_msg => "Checking scsi controllers"); |
| 62 |
$self->{components}->{scsictl} = {name => 'scsi controllers', total => 0, skip => 0}; |
| 63 |
return if ($self->check_filter(section => 'scsictl')); |
| 64 |
|
| 65 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqScsiCntlrEntry}})) { |
| 66 |
next if ($oid !~ /^$mapping->{cpqScsiCntlrStatus}->{oid}\.(.*)$/); |
| 67 |
my $instance = $1; |
| 68 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqScsiCntlrEntry}, instance => $instance); |
| 69 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqScsiCntlrCondition}, instance => $instance); |
| 70 |
|
| 71 |
next if ($self->check_filter(section => 'scsictl', instance => $instance)); |
| 72 |
$self->{components}->{scsictl}->{total}++; |
| 73 |
|
| 74 |
$self->{output}->output_add(long_msg => sprintf("scsi controller '%s' [slot: %s, status: %s] condition is %s.", |
| 75 |
$instance, $result->{cpqScsiCntlrSlot}, $result->{cpqScsiCntlrStatus}, |
| 76 |
$result2->{cpqScsiCntlrCondition})); |
| 77 |
my $exit = $self->get_severity(label => 'default', section => 'scsictl', value => $result2->{cpqScsiCntlrCondition}); |
| 78 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 79 |
$self->{output}->output_add(severity => $exit, |
| 80 |
short_msg => sprintf("scsi controller '%s' is %s", |
| 81 |
$instance, $result2->{cpqScsiCntlrCondition})); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
1; |