Debian Codegraph @

src/storage/dell/compellent/snmp/mode/components/ctrlfan.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 storage::dell::compellent::snmp::mode::components::ctrlfan;
22
23 use strict;
24 use warnings;
25 use storage::dell::compellent::snmp::mode::components::resources qw(%map_sc_status);
26
27 my $mapping = {
28 scCtlrFanStatus => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.3', map => \%map_sc_status },
29 scCtlrFanName => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.4' },
30 scCtlrFanCurrentRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.5' },
31 scCtlrFanWarnLwrRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.8' },
32 scCtlrFanWarnUprRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.9' },
33 scCtlrFanCritLwrRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.10' },
34 scCtlrFanCritUprRpm => { oid => '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1.11' }
35 };
36 my $oid_scCtlrFanEntry = '.1.3.6.1.4.1.674.11000.2000.500.1.2.16.1';
37
38 sub load {
39 my ($self) = @_;
40
41 push @{$self->{request}}, { oid => $oid_scCtlrFanEntry };
42 }
43
44 sub check {
45 my ($self) = @_;
46
47 $self->{output}->output_add(long_msg => "Checking controller fans");
48 $self->{components}->{ctrlfan} = {name => 'controller fans', total => 0, skip => 0};
49 return if ($self->check_filter(section => 'ctrlfan'));
50
51 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_scCtlrFanEntry}})) {
52 next if ($oid !~ /^$mapping->{scCtlrFanStatus}->{oid}\.(.*)$/);
53 my $instance = $1;
54 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_scCtlrFanEntry}, instance => $instance);
55
56 next if ($self->check_filter(section => 'ctrlfan', instance => $instance, name => $result->{scCtlrFanName}));
57
58 $self->{components}->{ctrlfan}->{total}++;
59
60 $self->{output}->output_add(
61 long_msg => sprintf(
62 "controller fan '%s' status is '%s' [instance: %s] [value: %s]",
63 $result->{scCtlrFanName}, $result->{scCtlrFanStatus}, $instance,
64 $result->{scCtlrFanCurrentRpm}
65 )
66 );
67
68 my $exit = $self->get_severity(label => 'default', section => 'ctrlfan', name => $result->{scCtlrFanName}, value => $result->{scCtlrFanStatus});
69 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
70 $self->{output}->output_add(
71 severity => $exit,
72 short_msg => sprintf("Controller fan '%s' status is '%s'", $result->{scCtlrFanName}, $result->{scCtlrFanStatus})
73 );
74 }
75
76 my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(
77 section => 'ctrlfan',
78 instance => $instance,
79 name => $result->{scCtlrFanName},
80 value => $result->{scCtlrFanCurrentRpm}
81 );
82 if ($checked == 0) {
83 $result->{scCtlrFanWarnLwrRpm} = (defined($result->{scCtlrFanWarnLwrRpm}) && $result->{scCtlrFanWarnLwrRpm} =~ /[0-9]/) ?
84 $result->{scCtlrFanWarnLwrRpm} : '';
85 $result->{scCtlrFanCritLwrRpm} = (defined($result->{scCtlrFanCritLwrRpm}) && $result->{scCtlrFanCritLwrRpm} =~ /[0-9]/) ?
86 $result->{scCtlrFanCritLwrRpm} : '';
87 $result->{scCtlrFanWarnUprRpm} = (defined($result->{scCtlrFanWarnUprRpm}) && $result->{scCtlrFanWarnUprRpm} =~ /[0-9]/) ?
88 $result->{scCtlrFanWarnUprRpm} : '';
89 $result->{scCtlrFanCritUprRpm} = (defined($result->{scCtlrFanCritUprRpm}) && $result->{scCtlrFanCritUprRpm} =~ /[0-9]/) ?
90 $result->{scCtlrFanCritUprRpm} : '';
91 my $warn_th = $result->{scCtlrFanWarnLwrRpm} . ':' . $result->{scCtlrFanWarnUprRpm};
92 my $crit_th = $result->{scCtlrFanCritLwrRpm} . ':' . $result->{scCtlrFanCritUprRpm};
93 $self->{perfdata}->threshold_validate(label => 'warning-ctrlfan-instance-' . $instance, value => $warn_th);
94 $self->{perfdata}->threshold_validate(label => 'critical-ctrlfan-instance-' . $instance, value => $crit_th);
95
96 $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-ctrlfan-instance-' . $instance);
97 $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-ctrlfan-instance-' . $instance);
98 }
99
100 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
101 $self->{output}->output_add(
102 severity => $exit2,
103 short_msg => sprintf("Controller fan '%s' is %s rpm", $result->{scCtlrFanName}, $result->{scCtlrFanCurrentRpm})
104 );
105 }
106
107 $self->{output}->perfdata_add(
108 label => 'ctrlfan', unit => 'rpm',
109 nlabel => 'hardware.controller.fan.speed.rpm',
110 instances => $instance,
111 value => $result->{scCtlrFanCurrentRpm},
112 warning => $warn,
113 critical => $crit,
114 min => 0
115 );
116 }
117 }
118
119 1;