Debian Codegraph @

src/hardware/sensors/apc/snmp/mode/sensors.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::sensors;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 use strict;
26 use warnings;
27
28 sub set_system {
29 my ($self, %options) = @_;
30
31 $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|humidity)$';
32
33 $self->{cb_hook2} = 'snmp_execute';
34
35 $self->{thresholds} = {
36 default => [
37 ['normal', 'OK'], # alarmStatus
38 ['warning', 'WARNING'], # alarmStatus
39 ['critical', 'CRITICAL'], # alarmStatus
40 ['ok', 'OK'], # commStatus
41 ['notInstalled', 'OK'], # commStatus
42 ['lost', 'WARNING'], # commStatus
43 ['^active', 'OK'], # commStatus
44 ['inactive', 'OK'] # commStatus
45 ]
46 };
47
48 $self->{components_path} = 'hardware::sensors::apc::snmp::mode::components';
49 $self->{components_module} = [
50 'temperature', 'humidity', 'fluid'
51 ];
52 }
53
54 sub snmp_execute {
55 my ($self, %options) = @_;
56
57 $self->{snmp} = $options{snmp};
58 $self->{checked_module_sensors} = 0;
59 $self->{checked_wireless_sensors} = 0;
60
61 my $oid_module_name = '.1.3.6.1.4.1.318.1.1.10.4.1.2.1.2';
62 my $snmp_result = $self->{snmp}->get_table(oid => $oid_module_name);
63 $self->{modules_name} = {};
64 foreach (keys %$snmp_result) {
65 /$oid_module_name\.(.*)$/;
66 $self->{modules_name}->{$1} = $snmp_result->{$_};
67 }
68
69 my $oid_emsStatusSysTempUnits = '.1.3.6.1.4.1.318.1.1.10.3.12.11.0';
70 $snmp_result = $self->{snmp}->get_leef(oids => [$oid_emsStatusSysTempUnits]);
71 $self->{temp_unit} = $snmp_result->{$oid_emsStatusSysTempUnits} == 1 ? 'C' : 'F';
72 }
73
74 sub new {
75 my ($class, %options) = @_;
76 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
77 bless $self, $class;
78
79 $options{options}->add_options(arguments => {});
80
81 return $self;
82 }
83
84 1;
85
86 __END__
87
88 =head1 MODE
89
90 Check sensors.
91
92 =over 8
93
94 =item B<--component>
95
96 Which component to check (default: '.*').
97 Can be: 'temperature', 'humidity', 'fluid'.
98
99 =item B<--filter>
100
101 Exclude the items given as a comma-separated list (example: --filter=temperature --filter=humidity).
102 You can also exclude items from specific instances: --filter=temperature,1
103
104 =item B<--no-component>
105
106 Define the expected status if no components are found (default: critical).
107
108 =item B<--threshold-overload>
109
110 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
111 Example: --threshold-overload='temperature,CRITICAL,^(?!(warning)$)'
112
113 =item B<--warning>
114
115 Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
116 Example: --warning='temperature,.*,30'
117
118 =item B<--critical>
119
120 Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
121 Example: --warning='temperature,.*,50'
122
123 =back
124
125 =cut