Debian Codegraph @

src/storage/netgear/readynas/snmp/mode/hardware.pm

raw
1 #
2 # Copyright 2018 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 # Author : ArnoMLT
21 #
22
23 package storage::netgear::readynas::snmp::mode::hardware;
24
25 use base qw(centreon::plugins::templates::hardware);
26
27 use strict;
28 use warnings;
29
30 sub set_system {
31 my ($self, %options) = @_;
32
33 $self->{regexp_threshold_numeric_check_section_option} = '^(fan|temperature)$';
34
35 $self->{cb_hook1} = 'init_mib_ver';
36 $self->{cb_hook2} = 'snmp_execute';
37
38 $self->{thresholds} = {
39 default => [
40 ['Normal', 'OK'],
41 ['Ok', 'OK'],
42 ['Unknown', 'CRITICAL'],
43 ['Failed', 'CRITICAL'],
44 ['n/a', 'OK' ]
45 ],
46 disk => [
47 ['Online', 'OK'],
48 ['Ok', 'OK'],
49 ['Unknown', 'OK'],
50 ['Offline', 'CRITICAL']
51 ],
52 psu => [
53 ['On', 'OK'],
54 ['Ok', 'OK'],
55 ['Off', 'CRITICAL'],
56 ['Unknown', 'CRITICAL']
57 ],
58 volume => [
59 ['Redundant', 'OK'],
60 ['Ok', 'OK'],
61 ['Unprotected', 'WARNING'],
62 ['Degraded', 'CRITICAL'],
63 ['Dead', 'CRITICAL'],
64 ['Unknown', 'CRITICAL']
65 ]
66 };
67
68 $self->{components_path} = 'storage::netgear::readynas::snmp::mode::components';
69 $self->{components_module} = ['psu', 'fan', 'disk', 'volume', 'temperature'];
70 }
71
72 sub init_mib_ver {
73 my ($self, %options) = @_;
74
75 # make the difference between READYNASOS-MIB (v6) and READYNAS-MIB (v4)
76 my $oid_MgrSoftwareVersion_v4 = '.1.3.6.1.4.1.4526.18.1.0';
77 my $oid_MgrSoftwareVersion_v6 = '.1.3.6.1.4.1.4526.22.1.0';
78
79 my $result = $options{snmp}->get_leef(oids => [$oid_MgrSoftwareVersion_v4, $oid_MgrSoftwareVersion_v6]);
80
81 $self->{mib_ver} = defined($result->{$oid_MgrSoftwareVersion_v4}) ? 'v4' : 'v6';
82 }
83
84 sub snmp_execute {
85 my ($self, %options) = @_;
86
87 $self->{snmp} = $options{snmp};
88 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
89 }
90
91 sub new {
92 my ($class, %options) = @_;
93 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
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 (READYNASOS-MIB, READYNAS-MIB) (Fans, Power Supplies, Disk status, Volume status, Temperatures).
108
109 =over 8
110
111 =item B<--component>
112
113 Which component to check (default: '.*').
114 Can be: 'psu', 'fan', 'disk', 'volume', 'temperature'.
115
116 =item B<--filter>
117
118 Exclude the items given as a comma-separated list (example: --filter=psu).
119 You can also exclude items from specific instances: --filter=psu,1
120
121 =item B<--no-component>
122
123 Define the expected status if no components are found (default: critical).
124
125 =item B<--threshold-overload>
126
127 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
128 Example: --threshold-overload='psu,CRITICAL,^(?!(on)$)'
129
130 =item B<--warning>
131
132 Set warning threshold for temperatures, fan (syntax: type,instance,threshold)
133 Example: --warning='xxxxx,.*,30'
134
135 =item B<--critical>
136
137 Set critical threshold for temperatures, fan (syntax: type,instance,threshold)
138 Example: --critical='xxxxx,.*,40'
139
140 =back
141
142 =cut