Debian Codegraph @

src/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.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::coolingdevice;
22
23 use strict;
24 use warnings;
25 use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state);
26
27 my $mapping = {
28 coolingDeviceStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.4', map => \%map_state },
29 coolingDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.5', map => \%map_probe_status },
30 coolingDeviceReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.6' },
31 coolingDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.8' },
32 coolingDeviceUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' },
33 coolingDeviceUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' },
34 coolingDeviceLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' },
35 coolingDeviceLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.12.1.13' }
36 };
37 my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.12.1';
38
39 sub load {
40 my ($self) = @_;
41
42 push @{$self->{request}}, {
43 oid => $oid_coolingDeviceTableEntry,
44 start => $mapping->{coolingDeviceStateSettings}->{oid},
45 end => $mapping->{coolingDeviceLowerCriticalThreshold}->{oid}
46 };
47 }
48
49 sub check {
50 my ($self) = @_;
51
52 $self->{output}->output_add(long_msg => "Checking cooling devices");
53 $self->{components}->{coolingdevice} = {name => 'cooling devices', total => 0, skip => 0};
54 return if ($self->check_filter(section => 'coolingdevice'));
55
56 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) {
57 next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(\d+)\.(\d+)$/);
58 my $instance = $1 . '.' . $2;
59 my $chassis_name = $self->get_chassis_name(id => $1);
60 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance);
61
62 next if ($self->check_filter(section => 'coolingdevice', instance => $instance, name => $result->{coolingDeviceLocationName}));
63 $self->{components}->{coolingdevice}->{total}++;
64
65 $result->{coolingDeviceReading} = (defined($result->{coolingDeviceReading})) ? $result->{coolingDeviceReading} : 'unknown';
66 $self->{output}->output_add(
67 long_msg => sprintf(
68 "cooling device '%s' status is '%s' [instance: %s] [state: %s] [value: %s]",
69 $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus}, $instance,
70 $result->{coolingDeviceStateSettings}, $result->{coolingDeviceReading}
71 )
72 );
73
74 my $exit = $self->get_severity(label => 'default.state', section => 'coolingdevice.state', value => $result->{coolingDeviceStateSettings});
75 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
76 $self->{output}->output_add(
77 severity => $exit,
78 short_msg => sprintf("Cooling device '%s' state is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStateSettings})
79 );
80 next;
81 }
82
83 $exit = $self->get_severity(label => 'probe.status', section => 'coolingdevice.status', value => $result->{coolingDeviceStatus});
84 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
85 $self->{output}->output_add(
86 severity => $exit,
87 short_msg => sprintf("Cooling device '%s' status is '%s'", $result->{coolingDeviceLocationName}, $result->{coolingDeviceStatus})
88 );
89 }
90
91 if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) {
92 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
93 section => 'coolingdevice',
94 instance => $instance,
95 name => $result->{coolingDeviceLocationName},
96 value => $result->{coolingDeviceReading}
97 );
98 if ($checked == 0) {
99 $result->{coolingDeviceLowerNonCriticalThreshold} = (defined($result->{coolingDeviceLowerNonCriticalThreshold}) && $result->{coolingDeviceLowerNonCriticalThreshold} =~ /[0-9]/) ?
100 $result->{coolingDeviceLowerNonCriticalThreshold} / 10 : '';
101 $result->{coolingDeviceLowerCriticalThreshold} = (defined($result->{coolingDeviceLowerCriticalThreshold}) && $result->{coolingDeviceLowerCriticalThreshold} =~ /[0-9]/) ?
102 $result->{coolingDeviceLowerCriticalThreshold} / 10 : '';
103 $result->{coolingDeviceUpperNonCriticalThreshold} = (defined($result->{coolingDeviceUpperNonCriticalThreshold}) && $result->{coolingDeviceUpperNonCriticalThreshold} =~ /[0-9]/) ?
104 $result->{coolingDeviceUpperNonCriticalThreshold} / 10 : '';
105 $result->{coolingDeviceUpperCriticalThreshold} = (defined($result->{coolingDeviceUpperCriticalThreshold}) && $result->{coolingDeviceUpperCriticalThreshold} =~ /[0-9]/) ?
106 $result->{coolingDeviceUpperCriticalThreshold} : '';
107 my $warn_th = $result->{coolingDeviceLowerNonCriticalThreshold} . ':' . $result->{coolingDeviceUpperNonCriticalThreshold};
108 my $crit_th = $result->{coolingDeviceLowerCriticalThreshold} . ':' . $result->{coolingDeviceUpperCriticalThreshold};
109 $self->{perfdata}->threshold_validate(label => 'warning-coolingdevice-instance-' . $instance, value => $warn_th);
110 $self->{perfdata}->threshold_validate(label => 'critical-coolingdevice-instance-' . $instance, value => $crit_th);
111
112 $exit = $self->{perfdata}->threshold_check(
113 value => $result->{coolingDeviceReading},
114 threshold => [
115 { label => 'critical-coolingdevice-instance-' . $instance, exit_litteral => 'critical' },
116 { label => 'warning-coolingdevice-instance-' . $instance, exit_litteral => 'warning' }
117 ]
118 );
119 $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-coolingdevice-instance-' . $instance);
120 $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-coolingdevice-instance-' . $instance);
121 }
122
123 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
124 $self->{output}->output_add(
125 severity => $exit,
126 short_msg => sprintf("Cooling device '%s' is %s rpm", $result->{coolingDeviceLocationName}, $result->{coolingDeviceReading})
127 );
128 }
129 $self->{output}->perfdata_add(
130 nlabel => 'hardware.fan.speed.rpm',
131 unit => 'rpm',
132 instances => [$chassis_name, $result->{coolingDeviceLocationName}],
133 value => $result->{coolingDeviceReading},
134 warning => $warn,
135 critical => $crit
136 );
137 }
138 }
139 }
140
141 1;