Debian Codegraph @

src/hardware/server/dell/idrac/snmp/mode/components/health.pm

raw
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::dell::idrac::snmp::mode::components::health;
22
23 use strict;
24 use warnings;
25 use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status);
26
27 my $mapping_health = {
28 psuComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.9', map => \%map_status, label => 'psuAll' }, # systemStatePowerSupplyStatusCombined
29 voltageComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.12', map => \%map_status, label => 'voltageAll' }, # systemStateVoltageStatusCombined
30 amperageComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.15', map => \%map_status, label => 'amperageAll' }, # systemStateAmperageStatusCombined
31 coolingDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.21', map => \%map_status, label => 'coolingDeviceAll' }, # systemStateCoolingDeviceStatusCombined
32 tempComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.24', map => \%map_status, label => 'temperatureAll' }, # systemStateTemperatureStatusCombined
33 memoryComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.27', map => \%map_status, label => 'memoryAll' }, # systemStateMemoryDeviceStatusCombined
34 intrusionComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.30', map => \%map_status, label => 'intrusionAll' }, # systemStateChassisIntrusionStatusCombined
35 powerComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.42', map => \%map_status, label => 'powerUnitAll' }, # systemStatePowerUnitStatusCombined
36 coolingUnitComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.44', map => \%map_status, label => 'coolingUnitAll' }, # systemStateCoolingUnitStatusCombined
37 processorComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.50', map => \%map_status, label => 'processorAll' }, # systemStateProcessorDeviceStatusCombined
38 batteryComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.52', map => \%map_status, label => 'batteryAll' }, # systemStateBatteryStatusCombined
39 sdCardUnitComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.54', map => \%map_status, label => 'sdCardUnitAll' }, # systemStateSDCardUnitStatusCombined
40 sdCardDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.56', map => \%map_status, label => 'sdCardDeviceAll' }, # systemStateSDCardDeviceStatusCombined
41 idsmCardDevComb => { oid => '.1.3.6.1.4.1.674.10892.5.4.200.10.1.60', map => \%map_status, label => 'idsmCardDeviceAll' } # systemStateIDSDMCardDeviceStatusCombined
42 };
43
44 sub load {}
45
46 sub check {
47 my ($self) = @_;
48
49 $self->{output}->output_add(long_msg => "Checking health");
50 $self->{components}->{health} = { name => 'health', total => 0, skip => 0 };
51 return if ($self->check_filter(section => 'health'));
52
53 my $instances = $self->get_chassis_instances();
54
55 return if (scalar(@$instances) <= 0);
56
57 $self->{snmp}->load(
58 oids => [map($_->{oid}, values(%$mapping_health))],
59 instances => $instances
60 );
61 my $results = $self->{snmp}->get_leef();
62
63 foreach my $instance (@$instances) {
64 my $result = $self->{snmp}->map_instance(mapping => $mapping_health, results => $results, instance => $instance);
65 my $chassis_name = $self->get_chassis_name(id => $instance);
66
67 foreach (keys %$mapping_health) {
68 next if (!defined($result->{$_}));
69
70 my $name = $chassis_name . ':' . $mapping_health->{$_}->{label};
71 next if ($self->check_filter(section => 'health', instance => $instance, name => $name));
72 $self->{components}->{health}->{total}++;
73
74 $self->{output}->output_add(
75 long_msg => sprintf(
76 "health '%s' status is %s [instance: %s]",
77 $name,
78 $result->{$_},
79 $instance
80 )
81 );
82 my $exit = $self->get_severity(label => 'default.status', section => 'health', value => $result->{$_});
83 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
84 $self->{output}->output_add(
85 severity => $exit,
86 short_msg => sprintf("Health '%s' status is %s", $name, $result->{$_})
87 );
88 }
89 }
90 }
91 }
92
93 1;