Debian Codegraph @

src/hardware/server/dell/cmc/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::cmc::snmp::mode::components::health;
22
23 use strict;
24 use warnings;
25 use hardware::server::dell::cmc::snmp::mode::components::resources qw($map_status);
26
27 # In MIB 'DELL-RAC-MIB'
28 my $mapping = {
29 drsIOMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.2', map => $map_status, descr => 'IOM status' },
30 drsKVMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.3', map => $map_status, descr => 'iKVM status' },
31 drsRedCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.4', map => $map_status, descr => 'Redundancy status' },
32 drsPowerCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.5', map => $map_status, descr => 'Power status' },
33 drsFanCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.6', map => $map_status, descr => 'Fan status' },
34 drsBladeCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.7', map => $map_status, descr => 'Blade status' },
35 drsTempCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.8', map => $map_status, descr => 'Temperature status' },
36 drsCMCCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.2.3.1.9', map => $map_status, descr => 'CMC status' }
37 };
38 my $oid_drsStatusNowGroup = '.1.3.6.1.4.1.674.10892.2.3.1';
39
40 sub load {
41 my ($self) = @_;
42
43 push @{$self->{request}}, { oid => $oid_drsStatusNowGroup, start => $mapping->{drsIOMCurrStatus}->{oid}, end => $mapping->{drsCMCCurrStatus}->{oid} };
44 }
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 $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsStatusNowGroup}, instance => 0);
54 foreach my $probe (keys %{$mapping}) {
55 next if (!defined($result->{$probe}));
56 $mapping->{$probe}->{oid} =~ /\.(\d+)$/;
57 my $instance = $1;
58
59 next if ($self->check_filter(section => 'health', instance => $instance));
60 $self->{components}->{health}->{total}++;
61
62 $self->{output}->output_add(
63 long_msg => sprintf(
64 "%s is %s [instance: %s].",
65 $mapping->{$probe}->{descr},
66 $result->{$probe},
67 $instance
68 )
69 );
70 my $exit = $self->get_severity(label => 'default', section => 'health', value => $result->{$probe});
71 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
72 $self->{output}->output_add(
73 severity => $exit,
74 short_msg => sprintf(
75 "%s is %s",
76 $mapping->{$probe}->{descr},
77 $result->{$probe}
78 )
79 );
80 }
81 }
82 }
83
84 1;