| 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::ats::apc::snmp::mode::components::entity; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_com = (1 => 'atsNeverDiscovered', 2 => 'atsCommEstablished', 3 => 'atsCommLost'); |
| 27 |
my %map_redunt = (1 => 'atsRedundancyLost', 2 => 'atsFullyRedundant'); |
| 28 |
my %map_current = (1 => 'atsOverCurrent', 2 => 'atsCurrentOK'); |
| 29 |
my %map_power = (1 => 'atsPowerSupplyFailure', 2 => 'atsPowerSupplyOK'); |
| 30 |
my %map_fail = (1 => 'fail', 2 => 'ok'); |
| 31 |
my %map_sync = (1 => 'inSync', 2 => 'outOfSync'); |
| 32 |
|
| 33 |
my $mapping = { |
| 34 |
atsStatusCommStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.1', map => \%map_com, label => 'CommStatus' }, |
| 35 |
atsStatusRedundancyState => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.3', map => \%map_redunt, label => 'RedundancyState' }, |
| 36 |
atsStatusOverCurrentState => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.4', map => \%map_current, label => 'OverCurrentState' }, |
| 37 |
atsStatus5VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.5', map => \%map_power, label => '5VPowerSupply' }, |
| 38 |
atsStatus24VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.6', map => \%map_power, label => '24VPowerSupply' }, |
| 39 |
atsStatus24VSourceBPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.7', map => \%map_power, label => '24VSourceBPowerSupply' }, |
| 40 |
atsStatusPlus12VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.8', map => \%map_power, label => 'Plus12VPowerSupply' }, |
| 41 |
atsStatusMinus12VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.9', map => \%map_power, label => 'Minus12VPowerSupply' }, |
| 42 |
atsStatusSwitchStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.10', map => \%map_fail, label => 'SwitchStatus' }, |
| 43 |
atsStatusSourceAStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.12', map => \%map_fail, label => 'SourceAStatus' }, |
| 44 |
atsStatusSourceBStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.13', map => \%map_fail, label => 'SourceBStatus' }, |
| 45 |
atsStatusPhaseSyncStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.14', map => \%map_sync, label => 'PhaseSyncStatus' }, |
| 46 |
atsStatusVoltageOutStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.15', map => \%map_fail, label => 'VoltageOutStatus' }, |
| 47 |
atsStatusHardwareStatus => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.16', map => \%map_fail, label => 'HardwareStatus' }, |
| 48 |
atsStatus3dot3VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.17', map => \%map_power, label => '3dot3VPowerSupply' }, |
| 49 |
atsStatus1Dot0VPowerSupply => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.18', map => \%map_power, label => '1Dot0VPowerSupply' }, |
| 50 |
atsStatusVBoostSourceA => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.19', map => \%map_power, label => 'VBoostSourceA' }, |
| 51 |
atsStatusVBoostSourceB => { oid => '.1.3.6.1.4.1.318.1.1.8.5.1.20', map => \%map_power, label => 'VBoostSourceB' } |
| 52 |
}; |
| 53 |
|
| 54 |
my $oid_atsStatusDeviceStatus = '.1.3.6.1.4.1.318.1.1.8.5.1'; |
| 55 |
|
| 56 |
sub load { |
| 57 |
my ($self) = @_; |
| 58 |
|
| 59 |
push @{$self->{request}}, { oid => $oid_atsStatusDeviceStatus }; |
| 60 |
} |
| 61 |
|
| 62 |
sub check { |
| 63 |
my ($self) = @_; |
| 64 |
|
| 65 |
$self->{output}->output_add(long_msg => "Checking entities"); |
| 66 |
$self->{components}->{entity} = {name => 'entities', total => 0, skip => 0}; |
| 67 |
return if ($self->check_filter(section => 'entity')); |
| 68 |
|
| 69 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_atsStatusDeviceStatus}, instance => '0'); |
| 70 |
foreach (sort keys %{$mapping}) { |
| 71 |
next if ($self->check_filter(section => 'entity', instance => $mapping->{$_}->{label})); |
| 72 |
$self->{components}->{entity}->{total}++; |
| 73 |
|
| 74 |
$self->{output}->output_add(long_msg => sprintf("entity '%s' status is '%s' [instance = %s]", |
| 75 |
$mapping->{$_}->{label}, defined($result->{$_}) ? $result->{$_} : 'n/a', $mapping->{$_}->{label})); |
| 76 |
|
| 77 |
next if (!defined($result->{$_})); |
| 78 |
my $exit = $self->get_severity(section => 'entity', instance => $mapping->{$_}->{label}, value => $result->{$_}); |
| 79 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 80 |
$self->{output}->output_add(severity => $exit, |
| 81 |
short_msg => sprintf("Entity '%s' status is '%s'", $mapping->{$_}->{label}, $result->{$_})); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
1; |