Debian Codegraph @

src/hardware/sensors/apc/snmp/mode/components/fluid.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::sensors::apc::snmp::mode::components::fluid;
22
23 use strict;
24 use warnings;
25 use hardware::sensors::apc::snmp::mode::components::resources qw($map_alarm_status $map_comm_status2 $map_fluid_state);
26
27 sub load {}
28
29 sub check_module_fluid {
30 my ($self) = @_;
31
32 my $oid_memFluidSensorStatusTable = '.1.3.6.1.4.1.318.1.1.10.4.7.6';
33 my $mapping = {
34 name => { oid => '.1.3.6.1.4.1.318.1.1.10.4.7.6.1.3' }, # memFluidSensorStatusSensorName
35 state => { oid => '.1.3.6.1.4.1.318.1.1.10.4.7.6.1.5', map => $map_fluid_state }, # memFluidSensorStatusSensorState
36 alarmStatus => { oid => '.1.3.6.1.4.1.318.1.1.10.4.7.6.1.7', map => $map_alarm_status }, # memFluidStatusAlarmStatus
37 commStatus => { oid => '.1.3.6.1.4.1.318.1.1.10.4.7.6.1.8', map => $map_comm_status2 } # memFluidSensorCommStatus
38 };
39
40 my $snmp_result = $self->{snmp}->get_table(oid => $oid_memFluidSensorStatusTable);
41
42 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
43 next if ($oid !~ /^$mapping->{alarmStatus}->{oid}\.(\d+)\.(\d+)$/);
44
45 my $module_name = $self->{modules_name}->{$1};
46 my $instance = $1 . '.' . $2;
47 my $result = $self->{snmp}->map_instance(
48 mapping => $mapping,
49 results => $snmp_result,
50 instance => $instance
51 );
52
53 next if ($self->check_filter(section => 'fluid', instance => $instance));
54 $self->{components}->{fluid}->{total}++;
55
56 my $name = $module_name . ':' . $result->{name};
57 $self->{output}->output_add(
58 long_msg => sprintf(
59 "fluid '%s' alarm status is %s [instance: %s] [state: %s] [comm: %s]",
60 $name,
61 $result->{alarmStatus},
62 $instance,
63 $result->{state},
64 $result->{commStatus}
65 )
66 );
67
68 my $exit = $self->get_severity(label => 'default', section => 'fluid.alarm', value => $result->{alarmStatus});
69 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
70 $self->{output}->output_add(
71 severity => $exit,
72 short_msg => sprintf(
73 "Fluid '%s' alarm status is %s",
74 $name,
75 $result->{alarmStatus}
76 )
77 );
78 }
79
80 $exit = $self->get_severity(label => 'default', section => 'fluid.comm', value => $result->{commStatus});
81 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
82 $self->{output}->output_add(
83 severity => $exit,
84 short_msg => sprintf(
85 "Fluid '%s' communication status is %s",
86 $name,
87 $result->{commStatus}
88 )
89 );
90 }
91 }
92 }
93
94 sub check {
95 my ($self) = @_;
96
97 $self->{output}->output_add(long_msg => "Checking fluids");
98 $self->{components}->{fluid} = { name => 'fluid', total => 0, skip => 0 };
99 return if ($self->check_filter(section => 'fluid'));
100
101 check_module_fluid($self);
102 }
103
104 1;