Debian Codegraph @

src/storage/emc/datadomain/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 storage::emc::datadomain::snmp::mode::hardware;
22
23 use base qw(centreon::plugins::templates::hardware);
24
25 use strict;
26 use warnings;
27 use storage::emc::datadomain::snmp::lib::functions;
28
29 sub set_system {
30 my ($self, %options) = @_;
31
32 $self->{regexp_threshold_numeric_check_section_option} = '^(battery|temperature)$';
33
34 $self->{cb_hook1} = 'get_version'; # before the loads
35 $self->{cb_hook2} = 'snmp_execute';
36
37 $self->{thresholds} = {
38 fan => [
39 ['notfound', 'OK'],
40 ['ok', 'OK'],
41 ['failed', 'CRITICAL']
42 ],
43 temperature => [
44 ['failed', 'CRITICAL'],
45 ['ok', 'OK'],
46 ['notfound', 'OK'],
47 ['absent', 'OK'],
48 ['overheatWarning', 'WARNING'],
49 ['overheatCritical', 'CRITICAL']
50 ],
51 psu => [
52 ['absent', 'OK'],
53 ['ok', 'OK'],
54 ['failed', 'CRITICAL'],
55 ['faulty', 'WARNING'],
56 ['acnone', 'WARNING'],
57 ['unknown', 'UNKNOWN']
58 ],
59 disk => [
60 ['ok', 'OK'],
61 ['spare', 'OK'],
62 ['available', 'OK'],
63 ['unknown', 'UNKNOWN'],
64 ['absent', 'OK'],
65 ['failed', 'CRITICAL'],
66 ['reconstruction', 'WARNING'],
67 ['system', 'OK']
68 ],
69 battery => [
70 ['ok', 'OK'],
71 ['disabled', 'OK'],
72 ['discharged', 'WARNING'],
73 ['softdisabled', 'OK'],
74 ['UNKNOWN', 'UNKNOWN']
75 ]
76 };
77
78 $self->{components_path} = 'storage::emc::datadomain::snmp::mode::components';
79 $self->{components_module} = ['fan', 'temperature', 'psu', 'disk', 'battery'];
80 }
81
82 sub snmp_execute {
83 my ($self, %options) = @_;
84
85 $self->{snmp} = $options{snmp};
86 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
87 }
88
89 sub new {
90 my ($class, %options) = @_;
91 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
92 bless $self, $class;
93
94 $options{options}->add_options(arguments => {});
95
96 return $self;
97 }
98
99 sub get_version {
100 my ($self, %options) = @_;
101
102 my $oid_sysDescr = '.1.3.6.1.2.1.1.1.0'; # 'Data Domain OS 5.4.1.1-411752'
103 my $result = $options{snmp}->get_leef(oids => [ $oid_sysDescr ]);
104 if (!($self->{os_version} = storage::emc::datadomain::snmp::lib::functions::get_version(value => $result->{$oid_sysDescr}))) {
105 $self->{output}->output_add(
106 severity => 'UNKNOWN',
107 short_msg => 'Cannot get DataDomain OS version.'
108 );
109 $self->{output}->display();
110 $self->{output}->exit();
111 }
112
113 $self->{output}->output_add(long_msg => 'DataDomain OS version: ' . $self->{os_version} . '.');
114 }
115
116 1;
117
118 __END__
119
120 =head1 MODE
121
122 Check components (Fans, Power Supplies, Temperatures, Disks, Nvram Batteries).
123
124 =over 8
125
126 =item B<--component>
127
128 Which component to check (default: '.*').
129 Can be: 'psu', 'fan', 'disk', 'temperature', 'battery'.
130
131 =item B<--filter>
132
133 Exclude the items given as a comma-separated list (example: --filter=fan --filter=psu).
134 You can also exclude items from specific instances: --filter=psu,3.3
135
136 =item B<--absent-problem>
137
138 Return an error if an entity is not 'present' (default is skipping)
139 Can be specific or global: --absent-problem=psu,1
140
141 =item B<--no-component>
142
143 Define the expected status if no components are found (default: critical).
144
145 =item B<--threshold-overload>
146
147 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
148 Example: --threshold-overload='fan,CRITICAL,^(?!(ok)$)'
149
150 =item B<--warning>
151
152 Set warning threshold for temperatures (syntax: type,regexp,threshold)
153 Example: --warning='temperature,.*,20'
154
155 =item B<--critical>
156
157 Set critical threshold for temperatures and battery charge (syntax: type,regexp,threshold)
158 Example: --critical='temperature,1.1,25' --critical='battery,.*,20:'
159
160 =back
161
162 =cut
163