Debian Codegraph @

src/hardware/server/dell/cmc/snmp/mode/components/chassis.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::chassis;
22
23 use strict;
24 use warnings;
25
26 # In MIB 'DELL-RAC-MIB'
27 my $mapping = {
28 drsWattsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.13', section => 'power', label => 'power', unit => 'watt' },
29 drsAmpsReading => { oid => '.1.3.6.1.4.1.674.10892.2.4.1.1.14', section => 'current', label => 'current', unit => 'ampere' }
30 };
31 my $oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry = '.1.3.6.1.4.1.674.10892.2.4.1.1';
32
33 sub load {
34 my ($self) = @_;
35
36 push @{$self->{request}}, { oid => $oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry };
37 }
38
39 sub check {
40 my ($self) = @_;
41
42 $self->{output}->output_add(long_msg => "Checking chassis");
43 $self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 };
44 return if ($self->check_filter(section => 'chassis'));
45
46 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry}})) {
47 next if ($oid !~ /^$mapping->{drsWattsReading}->{oid}\.(.*)$/);
48 my $instance = $1;
49 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_drsCMCPowerTableEntrydrsCMCPowerTableEntry}, instance => $instance);
50
51 next if ($self->check_filter(section => 'chassis', instance => $instance));
52 $self->{components}->{chassis}->{total}++;
53
54 $self->{output}->output_add(
55 long_msg => sprintf(
56 "chassis '%s': power %s W, current %s A [instance: %s].",
57 $instance,
58 $result->{drsWattsReading},
59 $result->{drsAmpsReading},
60 $instance
61 )
62 );
63 foreach my $probe (('drsWattsReading', 'drsAmpsReading')) {
64 next if (!defined($result->{$probe}));
65 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'chassis.' . $mapping->{$probe}->{section}, instance => $instance, value => $result->{$probe});
66 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
67 $self->{output}->output_add(
68 severity => $exit,
69 short_msg => sprintf(
70 "Chassis '%s' %s is %s%s",
71 $instance,
72 $mapping->{$probe}->{section},
73 $result->{$probe},
74 $mapping->{$probe}->{unit}
75 )
76 );
77 }
78 $self->{output}->perfdata_add(
79 label => 'chassis_' . $mapping->{$probe}->{label}, unit => $mapping->{$probe}->{unit},
80 nlabel => 'hardware.chassis.' . $mapping->{$probe}->{label} . '.' . $mapping->{$probe}->{unit},
81 instances => $instance,
82 value => $result->{$probe},
83 warning => $warn,
84 critical => $crit
85 );
86 }
87 }
88 }
89
90 1;