Debian Codegraph @

src/hardware/server/hp/proliant/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::hp::proliant::snmp::mode::hardware;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::misc;
28
29 sub set_system {
30 my ($self, %options) = @_;
31
32 $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$';
33
34 $self->{cb_hook1} = 'get_system_information';
35 $self->{cb_hook2} = 'snmp_execute';
36
37 $self->{thresholds} = {
38 cpu => [
39 ['unknown', 'UNKNOWN'],
40 ['ok', 'OK'],
41 ['degraded', 'WARNING'],
42 ['failed', 'CRITICAL'],
43 ['disabled', 'OK']
44 ],
45 ideldrive => [
46 ['other', 'UNKNOWN'],
47 ['ok', 'OK'],
48 ['rebuilding', 'WARNING'],
49 ['degraded', 'WARNING'],
50 ['failed', 'CRITICAL']
51 ],
52 sasldrive => [
53 ['other', 'UNKNOWN'],
54 ['ok', 'OK'],
55 ['degraded', 'WARNING'],
56 ['rebuilding', 'WARNING'],
57 ['failed', 'CRITICAL'],
58 ['offline', 'CRITICAL']
59 ],
60 scsildrive => [
61 ['other', 'UNKNOWN'],
62 ['ok', 'OK'],
63 ['degraded', 'WARNING'],
64 ['failed', 'CRITICAL'],
65 ['unconfigured', 'OK'],
66 ['recovering', 'WARNING'],
67 ['readyForRebuild', 'WARNING'],
68 ['rebuilding', 'WARNING'],
69 ['wrongDrive', 'CRITICAL'],
70 ['badConnect', 'CRITICAL'],
71 ['disabled', 'OK']
72 ],
73 fcaexternalaccbattery => [
74 ['other', 'UNKNOWN'],
75 ['ok', 'OK'],
76 ['degraded', 'WARNING'],
77 ['failed', 'CRITICAL'],
78 ['recharging', 'WARNING'],
79 ['not present', 'OK']
80 ],
81 fcaldrive => [
82 ['other', 'UNKNOWN'],
83 ['ok', 'OK'],
84 ['failed', 'CRITICAL'],
85 ['rebuilding', 'WARNING'],
86 ['expanding', 'WARNING'],
87 ['recovering', 'WARNING'],
88 ['unconfigured', 'OK'],
89 ['readyForRebuild', 'WARNING'],
90 ['wrongDrive', 'CRITICAL'],
91 ['badConnect', 'CRITICAL'],
92 ['overheating', 'CRITICAL'],
93 ['notAvailable', 'WARNING'],
94 ['hardError', 'CRITICAL'],
95 ['queuedForExpansion', 'WARNING'],
96 ['shutdown', 'WARNING']
97 ],
98 daaccbattery => [
99 ['other', 'UNKNOWN'],
100 ['ok', 'OK'],
101 ['degraded', 'WARNING'],
102 ['failed', 'CRITICAL'],
103 ['recharging', 'WARNING'],
104 ['not present', 'OK']
105 ],
106 daldrive => [
107 ['other', 'UNKNOWN'],
108 ['ok', 'OK'],
109 ['failed', 'CRITICAL'],
110 ['rebuilding', 'WARNING'],
111 ['expanding', 'WARNING'],
112 ['recovering', 'WARNING'],
113 ['unconfigured', 'OK'],
114 ['readyForRebuild', 'WARNING'],
115 ['wrongDrive', 'CRITICAL'],
116 ['badConnect', 'CRITICAL'],
117 ['overheating', 'CRITICAL'],
118 ['notAvailable', 'WARNING'],
119 ['hardError', 'CRITICAL'],
120 ['queuedForExpansion', 'WARNING'],
121 ['shutdown', 'WARNING']
122 ],
123 lnic => [
124 ['other', 'OK'],
125 ['ok', 'OK'],
126 ['degraded', 'WARNING'],
127 ['failed', 'CRITICAL']
128 ],
129 temperature => [
130 ['other', 'OK'],
131 ['ok', 'OK'],
132 ['degraded', 'WARNING'],
133 ['failed', 'CRITICAL']
134 ],
135 memory => [
136 ['other', 'OK'],
137 ['notPresent', 'OK'],
138 ['present', 'OK'],
139 ['good', 'OK'],
140 ['add', 'OK'],
141 ['upgrade', 'OK'],
142 ['missing', 'CRITICAL'],
143 ['doesNotMatch', 'CRITICAL'],
144 ['notSupported', 'CRITICAL'],
145 ['badConfig', 'CRITICAL'],
146 ['degraded', 'WARNING'],
147 ['spare', 'OK'],
148 ['partial', 'OK'],
149 ['configError', 'CRITICAL'],
150 ['trainingFailure', 'CRITICAL']
151 ],
152 # ilo, pnic, fan, dapdrive, daacc, dactl, fcapdrive, fcaexternalacc, fcaexternalctl, fcahostctl, scsipdrive, scsictl, saspdrive, sasctl, psu, pc, idepdrive, idectl
153 default => [
154 ['other', 'UNKNOWN'],
155 ['ok', 'OK'],
156 ['degraded', 'WARNING'],
157 ['failed', 'CRITICAL']
158 ]
159 };
160
161 $self->{components_path} = 'hardware::server::hp::proliant::snmp::mode::components';
162 $self->{components_module} = [
163 'cpu', 'idectl', 'ideldrive', 'idepdrive', 'pc', 'psu',
164 'sasctl', 'sasldrive', 'saspdrive', 'scsictl', 'scsildrive', 'scsipdrive',
165 'fcahostctl', 'fcaexternalctl', 'fcaexternalacc', 'fcaldrive', 'fcapdrive',
166 'dactl', 'daacc', 'daldrive', 'dapdrive', 'fan', 'pnic', 'lnic', 'temperature', 'ilo', 'memory'
167 ];
168 }
169
170 sub snmp_execute {
171 my ($self, %options) = @_;
172
173 $self->{snmp} = $options{snmp};
174 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
175 }
176
177 sub new {
178 my ($class, %options) = @_;
179 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
180 bless $self, $class;
181
182 $options{options}->add_options(arguments => {});
183
184 return $self;
185 }
186
187 sub check_options {
188 my ($self, %options) = @_;
189 $self->SUPER::check_options(%options);
190
191 if ($self->{option_results}->{component} =~ /storage/i) {
192 $self->{option_results}->{component} = '^(sas|ide|fca|da|scsi).*';
193 }
194 if ($self->{option_results}->{component} =~ /network/i) {
195 $self->{option_results}->{component} = '^(pnic|lnic)$';
196 }
197 }
198
199 sub get_system_information {
200 my ($self, %options) = @_;
201
202 # In 'CPQSINFO-MIB'
203 my $oid_cpqSiSysSerialNum = ".1.3.6.1.4.1.232.2.2.2.1.0";
204 my $oid_cpqSiProductName = ".1.3.6.1.4.1.232.2.2.4.2.0";
205 my $oid_cpqSeSysRomVer = ".1.3.6.1.4.1.232.1.2.6.1.0";
206
207 my $result = $options{snmp}->get_leef(oids => [$oid_cpqSiSysSerialNum, $oid_cpqSiProductName, $oid_cpqSeSysRomVer]);
208
209 my $product_name = defined($result->{$oid_cpqSiProductName}) ? centreon::plugins::misc::trim($result->{$oid_cpqSiProductName}) : 'unknown';
210 my $serial = defined($result->{$oid_cpqSiSysSerialNum}) ? centreon::plugins::misc::trim($result->{$oid_cpqSiSysSerialNum}) : 'unknown';
211 my $romversion = defined($result->{$oid_cpqSeSysRomVer}) ? centreon::plugins::misc::trim($result->{$oid_cpqSeSysRomVer}) : 'unknown';
212 $self->{output}->output_add(long_msg => sprintf("Product Name: %s, Serial: %s, Rom Version: %s",
213 $product_name, $serial, $romversion)
214 );
215 }
216
217 1;
218
219 __END__
220
221 =head1 MODE
222
223 Check Hardware (CPUs, Power Supplies, Power converters, Fans).
224
225 =over 8
226
227 =item B<--component>
228
229 Which component to check (default: '.*').
230 Can be: 'cpu', 'psu', 'pc', 'fan', 'temperature', 'lnic', 'pnic',...
231 There are some magic words like: 'network', 'storage'.
232
233 =item B<--filter>
234
235 Exclude the items given as a comma-separated list (example: --filter=fan --filter=temperature).
236 You can also exclude items from specific instances: --filter=fan,1.2 --filter=lnic,1
237
238 =item B<--absent-problem>
239
240 Return an error if an entity is not 'present' (default is skipping
241 Can be specific or global: --absent-problem=fan,1.2
242
243 =item B<--no-component>
244
245 Define the expected status if no components are found (default: critical).
246
247 =item B<--threshold-overload>
248
249 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp).
250 Example: --threshold-overload='temperature,CRITICAL,^(?!(ok)$)'
251
252 =item B<--warning>
253
254 Set warning threshold for temperatures (syntax: type,regexp,threshold)
255 Example: --warning='temperature,.*,30'
256
257 =item B<--critical>
258
259 Set critical threshold for temperatures (syntax: type,regexp,threshold)
260 Example: --critical='temperature,.*,40'
261
262 =back
263
264 =cut