Debian Codegraph @

src/hardware/server/fujitsu/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 hardware::server::fujitsu::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|fan|voltage|power)$';
32
33 $self->{cb_hook2} = 'snmp_execute';
34
35 $self->{thresholds} = {
36 cpu => [
37 ['unknown', 'UNKNOWN'],
38 ['disabled', 'OK'],
39 ['ok', 'OK'],
40 ['not-present', 'OK'],
41 ['error', 'CRITICAL'],
42 ['prefailure-warning', 'WARNING'],
43 ['fail', 'CRITICAL'], # can be failed also
44 ['missing-termination', 'WARNING']
45 ],
46 disk => [
47 ['unknown', 'UNKNOWN'],
48 ['noDisk', 'OK'],
49 ['online', 'OK'],
50 ['ready', 'OK'],
51 ['failed', 'CRITICAL'],
52 ['rebuilding', 'WARNING'],
53 ['hotspareGlobal', 'OK'],
54 ['hotspareDedicated', 'OK'],
55 ['offline', 'OK'],
56 ['unconfiguredFailed', 'WARNING'],
57 ['formatting', 'WARNING'],
58 ['dead', 'CRITICAL']
59 ],
60 fan => [
61 ['unknown', 'UNKNOWN'],
62 ['disabled', 'OK'],
63 ['ok', 'OK'],
64 ['prefailure-predicted', 'WARNING'],
65 ['fail', 'CRITICAL'],
66 ['redundant-fan-failed', 'WARNING'],
67 ['not-manageable', 'OK'],
68 ['not-present', 'OK'],
69 ],
70 memory => [
71 ['unknown', 'UNKNOWN'],
72 ['not-present|not-available', 'OK'],
73 ['ok', 'OK'],
74 ['disabled', 'OK'],
75 ['error', 'CRITICAL'],
76 ['prefailure-predicted|prefailure-warning', 'WARNING'],
77 ['fail', 'CRITICAL'], # can be failed
78 ['disabled', 'OK'],
79 ['hot-spare', 'OK'],
80 ['mirror', 'OK'],
81 ['raid', 'OK'],
82 ['hidden', 'OK']
83 ],
84 psu => [
85 ['unknown', 'UNKNOWN'],
86 ['not-present', 'OK'],
87 ['ok', 'OK'],
88 ['ac-fail', 'CRITICAL'],
89 ['dc-fail', 'CRITICAL'],
90 ['failed', 'CRITICAL'],
91 ['critical-temperature', 'CRITICAL'],
92 ['not-manageable', 'OK'],
93 ['fan-failure-predicted', 'WARNING'],
94 ['fan-failure', 'CRITICAL'],
95 ['power-safe-mode', 'WARNING'],
96 ['non-redundant-dc-fail', 'WARNING'],
97 ['non-redundant-ac-fail', 'WARNING'],
98
99 ['degraded', 'WARNING'],
100 ['critical', 'CRITICAL']
101 ],
102 raid => [
103 ['unknown', 'UNKNOWN'],
104 ['online', 'OK'],
105 ['degraded', 'WARNING'],
106 ['offline', 'ok'],
107 ['rebuilding', 'WARNING'],
108 ['verifying', 'OK'],
109 ['initializing', 'OK'],
110 ['morphing', 'OK'],
111 ['partialDegraded', 'WARNING']
112 ],
113 temperature => [
114 ['unknown', 'UNKNOWN'],
115 ['sensor-disabled', 'OK'],
116 ['ok', 'OK'],
117 ['sensor-fail', 'CRITICAL'], # can be also sensor-failed
118 ['warning-temp-warm', 'WARNING'],
119 ['warning-temp-cold', 'WARNING'],
120 ['critical-temp-warm', 'CRITICAL'],
121 ['critical-temp-cold', 'CRITICAL'],
122 ['damage-temp-warm', 'WARNING'],
123 ['damage-temp-cold', 'CRITICAL'],
124 ['not-available', 'OK'],
125 ['temperature-warning', 'WARNING'], # can be also temperature-warning-toohot
126 ['temperature-critical-toohot', 'CRITICAL'],
127 ['temperature-normal', 'OK']
128 ],
129 voltage => [
130 ['unknown', 'UNKNOWN'],
131 ['not-available', 'OK'],
132 ['ok', 'OK'],
133 ['too-low', 'WARNING'],
134 ['too-high', 'WARNING'],
135 ['out-of-range', 'CRITICAL'],
136 ['battery-prefailure', 'CRITICAL'],
137 ['warning', 'WARNING']
138 ]
139 };
140
141 $self->{components_path} = 'hardware::server::fujitsu::snmp::mode::components';
142 $self->{components_module} = ['cpu', 'disk', 'fan', 'memory', 'psu', 'raid', 'temperature', 'voltage'];
143 }
144
145 sub snmp_execute {
146 my ($self, %options) = @_;
147
148 $self->{snmp} = $options{snmp};
149 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
150 }
151
152 sub new {
153 my ($class, %options) = @_;
154 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
155 bless $self, $class;
156
157 $options{options}->add_options(arguments => {});
158
159 return $self;
160 }
161
162 1;
163
164 __END__
165
166 =head1 MODE
167
168 Check hardware.
169
170 =over 8
171
172 =item B<--component>
173
174 Which component to check (default: '.*').
175 Can be: 'temperature', 'fan', 'psu', 'voltage', 'cpu', 'memory'.
176
177 =item B<--filter>
178
179 Exclude the items given as a comma-separated list (example: --filter=temperature).
180 You can also exclude items from specific instances: --filter=temperature,1
181
182 =item B<--absent-problem>
183
184 Return an error if an entity is not 'present' (default is skipping)
185 Can be specific or global: --absent-problem="fan,1.1"
186
187 =item B<--no-component>
188
189 Define the expected status if no components are found (default: critical).
190
191 =item B<--threshold-overload>
192
193 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
194 Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)'
195
196 =item B<--warning>
197
198 Set warning threshold (syntax: type,regexp,threshold)
199 Example: --warning='temperature,.*,30'
200
201 =item B<--critical>
202
203 Set critical threshold (syntax: type,regexp,threshold)
204 Example: --critical='temperature,.*,40'
205
206 =back
207
208 =cut