Debian Codegraph @

src/storage/qnap/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::qnap::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} =
32 '^(?:temperature|disk|smartdisk|fan|psu\.fanspeed|psu\.temperature)$';
33
34 $self->{cb_hook2} = 'snmp_execute';
35
36 $self->{thresholds} = {
37 disk => [
38 ['good', 'OK'],
39 ['warning', 'WARNING'],
40 ['abnormal', 'CRITICAL'],
41
42 ['in-use', 'OK'], # es
43 ['noDisk', 'OK'],
44 ['ready', 'OK'],
45 ['invalid', 'CRITICAL'],
46 ['rwError', 'CRITICAL'],
47 ['unknown', 'UNKNOWN'],
48 ['error', 'CRITICAL']
49 ],
50 fan => [
51 ['ok', 'OK'],
52 ['n/a', 'OK'],
53 ['fail', 'CRITICAL']
54 ],
55 psu => [
56 ['ok', 'OK'],
57 ['fail', 'CRITICAL']
58 ],
59 smartdisk => [
60 ['good', 'OK'],
61 ['warning', 'WARNING'],
62 ['abnormal', 'CRITICAL'],
63 ['error', 'CRITICAL'],
64
65 ['GOOD', 'OK'],
66 ['NORMAL', 'OK'],
67 ['--', 'OK'],
68 ['.*', 'CRITICAL']
69 ],
70 raid => [
71 ['Ready', 'OK'],
72 ['Synchronizing', 'OK'],
73 ['degraded', 'WARNING'],
74 ['.*', 'CRITICAL']
75 ]
76 };
77
78 $self->{components_path} = 'storage::qnap::snmp::mode::components';
79 $self->{components_module} = ['disk', 'fan', 'mdisk', 'psu', 'raid', 'temperature'];
80 }
81
82 sub snmp_execute {
83 my ($self, %options) = @_;
84
85 $self->{snmp} = $options{snmp};
86
87 $self->{is_es} = 0;
88 $self->{is_qts} = 0;
89 my $oid_es_uptime = '.1.3.6.1.4.1.24681.2.2.4.0'; # es-SystemUptime
90 my $oid_qts_model = '.1.3.6.1.4.1.55062.1.12.3.0'; # systemModel
91 my $snmp_result = $self->{snmp}->get_leef(
92 oids => [$oid_es_uptime, $oid_qts_model]
93 );
94 if (defined($snmp_result->{$oid_es_uptime})) {
95 $self->{is_es} = 1;
96 }
97 if (defined($snmp_result->{$oid_qts_model})) {
98 $self->{is_qts} = 1;
99 }
100 }
101
102 sub new {
103 my ($class, %options) = @_;
104 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
105 bless $self, $class;
106
107 $options{options}->add_options(arguments => {});
108
109 return $self;
110 }
111
112 1;
113
114 __END__
115
116 =head1 MODE
117
118 Check hardware.
119
120 =over 8
121
122 =item B<--component>
123
124 Which component to check (default: '.*').
125 Can be: 'disk', 'fan', 'mdisk', 'psu', 'raid', 'temperature'.
126
127 =item B<--filter>
128
129 Exclude the items given as a comma-separated list (example: --filter=disk).
130 You can also exclude items from specific instances: --filter=disk,1
131
132 =item B<--absent-problem>
133
134 Return an error if an entity is not 'present' (default is skipping) (comma separated list)
135 Can be specific or global: --absent-problem=disk
136
137 =item B<--no-component>
138
139 Define the expected status if no components are found (default: critical).
140
141 =item B<--threshold-overload>
142
143 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,status,regexp).
144 Example: --threshold-overload='disk,CRITICAL,^(?!(ready)$)'
145
146 =item B<--warning>
147
148 Set warning threshold for temperatures (syntax: type,regexp,threshold)
149 Example: --warning='temperature,cpu,30' --warning='fan,.*,1500'
150
151 =item B<--critical>
152
153 Set critical threshold for temperatures (syntax: type,regexp,threshold)
154 Example: --critical='temperature,system,40' --critical='disk,.*,40'
155
156 =back
157
158 =cut