Debian Codegraph @

src/storage/synology/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::synology::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} = '^(?:disk.badsectors)$';
32
33 $self->{cb_hook2} = 'snmp_execute';
34
35 $self->{thresholds} = {
36 # system, fan, psu
37 default => [
38 ['Normal', 'OK'],
39 ['Failed', 'CRITICAL']
40 ],
41 disk => [
42 ['Normal', 'OK'],
43 ['Initialized', 'OK'],
44 ['NotInitialized', 'OK'],
45 ['SystemPartitionFailed', 'CRITICAL'],
46 ['Crashed', 'CRITICAL'],
47
48 ['warning', 'WARNING'],
49 ['critical', 'CRITICAL'],
50 ['failing', 'CRITICAL']
51 ],
52 raid => [
53 ['Normal', 'OK'],
54 ['Repairing', 'OK'],
55 ['Migrating', 'OK'],
56 ['Expanding', 'OK'],
57 ['Deleting', 'OK'],
58 ['Creating', 'OK'],
59 ['RaidSyncing', 'OK'],
60 ['RaidParityChecking', 'OK'],
61 ['RaidAssembling', 'OK'],
62 ['Canceling', 'OK'],
63 ['Degrade', 'WARNING'],
64 ['Crashed', 'CRITICAL'],
65 ['DataScrubbing', 'OK'],
66 ['RaidDeploying', 'OK'],
67 ['RaidUnDeploying', 'OK'],
68 ['RaidMountCache', 'OK'],
69 ['RaidUnmountCache', 'OK'],
70 ['RaidExpandingUnfinishedSHR', 'OK'],
71 ['RaidConvertSHRToPool', 'OK'],
72 ['RaidMigrateSHR1ToSHR2', 'OK'],
73 ['RaidUnknownStatus', 'UNKNOWN']
74 ]
75 };
76
77 $self->{components_path} = 'storage::synology::snmp::mode::components';
78 $self->{components_module} = ['disk', 'fan', 'psu', 'raid', 'system'];
79
80 $self->{request_leef} = [];
81 }
82
83 sub snmp_execute {
84 my ($self, %options) = @_;
85
86 $self->{snmp} = $options{snmp};
87 if (scalar(@{$self->{request}}) > 0) {
88 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
89 }
90 if (scalar(@{$self->{request_leef}}) > 0) {
91 $self->{results_leef} = $self->{snmp}->get_leef(oids => $self->{request_leef});
92 }
93 }
94
95 sub new {
96 my ($class, %options) = @_;
97 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
98 bless $self, $class;
99
100 $options{options}->add_options(arguments => {});
101
102 return $self;
103 }
104
105 1;
106
107 __END__
108
109 =head1 MODE
110
111 Check hardware.
112
113 =over 8
114
115 =item B<--component>
116
117 Filter the components to monitor with a regular expression (default: '.*').
118 Available components: psu, fan, disk, raid, system.
119
120 =item B<--filter>
121
122 Exclude the items given as a comma-separated list (example: --filter=psu).
123 You can also exclude items from specific instances: --filter=psu,1
124
125 =item B<--no-component>
126
127 Define the expected status if no components are found (default: critical).
128
129 =item B<--threshold-overload>
130
131 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
132 Example: --threshold-overload='psu,CRITICAL,^(?!(on)$)'
133
134 =item B<--warning>
135
136 Set warning threshold for 'disk.badsectors' (syntax: type,regexp,threshold)
137 Example: --warning='disk.badsectors,.*,30'
138
139 =item B<--critical>
140
141 Set critical threshold for 'disk.badsectors' (syntax: type,regexp,threshold)
142 Example: --critical='disk.badsectors,.*,50'
143
144 =back
145
146 =cut