Debian Codegraph @

src/network/microsens/g6/snmp/mode/hardware.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 network::microsens::g6::snmp::mode::hardware;
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)$';
32
33 $self->{cb_hook2} = 'snmp_execute';
34
35 $self->{thresholds} = {
36 fan => [
37 ['ok', 'OK'],
38 ['unused', 'OK'],
39 ['degraded', 'WARNING'],
40 ['fail', 'CRITICAL'],
41 ['missing', 'OK']
42 ],
43 psu => [
44 ['ok', 'OK'],
45 ['overload', 'WARNING'],
46 ['inputLow', 'OK'],
47 ['fuseFail', 'CRITICAL'],
48 ['notApplicable', 'OK'],
49 ['unmanaged', 'OK'],
50 ['notInstalled', 'OK'],
51 ],
52 sdcard => [
53 ['empty', 'OK'],
54 ['inserted', 'OK'],
55 ['writeProtected', 'OK'],
56 ['writing', 'OK']
57 ]
58 };
59
60 $self->{components_path} = 'network::microsens::g6::snmp::mode::components';
61 $self->{components_module} = ['fan', 'psu', 'sdcard', 'temperature'];
62 }
63
64 sub snmp_execute {
65 my ($self, %options) = @_;
66
67 my $map_psu_status = {
68 0 => 'ok', 1 => 'overload', 2 => 'inputLow',
69 3 => 'fuseFail', 4 => 'notApplicable',
70 5 => 'unmanaged', 6 => 'notInstalled'
71 };
72 my $map_fan_status = {
73 0 => 'unused', 1 => 'ok', 2 => 'degraded',
74 3 => 'fail', 4 => 'missing'
75 };
76 my $map_sdcard_status = {
77 0 => 'empty', 1 => 'inserted', 2 => 'writeProtected', 3 => 'writing'
78 };
79 my $mapping = {
80 system_temp => { oid => '.1.3.6.1.4.1.3181.10.6.1.30.104' }, # systemTemperature
81 psu1_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.100', map => $map_psu_status }, # hardwarePowerSupply1Status
82 psu2_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.101', map => $map_psu_status }, # hardwarePowerSupply2Status
83 fan_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.103', map => $map_fan_status }, # hardwareFanStatus
84 sdcard_status => { oid => '.1.3.6.1.4.1.3181.10.6.1.31.104', map => $map_sdcard_status } # hardwareSdCardStatus
85 };
86
87 my $snmp_result = $options{snmp}->get_leef(oids => [ map($_->{oid} . '.0', values(%$mapping)) ]);
88 $self->{results} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
89 }
90
91 sub new {
92 my ($class, %options) = @_;
93 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
94 bless $self, $class;
95
96 $options{options}->add_options(arguments => {});
97
98 return $self;
99 }
100
101 1;
102
103 __END__
104
105 =head1 MODE
106
107 Check hardware.
108
109 =over 8
110
111 =item B<--component>
112
113 Which component to check (default: '.*').
114 Can be: 'fan', 'psu', 'sdcard', 'temperature'.
115
116 =item B<--filter>
117
118 Exclude the items given as a comma-separated list (example: --filter=fan).
119 You can also exclude items from specific instances: --filter=psu,2
120
121 =item B<--no-component>
122
123 Define the expected status if no components are found (default: critical).
124
125
126 =item B<--threshold-overload>
127
128 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
129 Example: --threshold-overload='sdcard,WARNING,empty'
130
131 =item B<--warning>
132
133 Set warning threshold for 'temperature' (syntax: type,regexp,threshold)
134 Example: --warning='temperature,.*,40'
135
136 =item B<--critical>
137
138 Set critical threshold for 'temperature' (syntax: type,regexp,threshold)
139 Example: --critical='temperature,.*,50'
140
141 =back
142
143 =cut