Debian Codegraph @

src/network/fiberstore/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 network::fiberstore::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 '^(?:fan\.speed)$';
33
34 $self->{cb_hook1} = 'check_version';
35 $self->{cb_hook2} = 'get_informations';
36
37 $self->{thresholds} = {
38 fan => [
39 ['active', 'OK'],
40 ['deactive', 'OK'],
41 ['notInstall', 'OK'],
42 ['unsupport', 'UNKNOWN']
43 ],
44 power => [
45 ['noAlert', 'OK'],
46 ['alert', 'CRITICAL'],
47 ['unsupported', 'OK']
48 ],
49 slot => [
50 ['absent', 'OK'],
51 ['creating', 'OK'],
52 ['initing', 'OK'],
53 ['syncing', 'OK'],
54 ['fail', 'CRITICAL'],
55 ['ready', 'OK'],
56 ['uninit', 'WARNING'],
57 ['conflict', 'CRITICAL']
58 ],
59 };
60
61 $self->{components_path} = 'network::fiberstore::snmp::mode::components';
62 $self->{components_module} = ['fan', 'power', 'slot'];
63 }
64
65 sub check_version {
66 my ($self, %options) = @_;
67
68 $self->{snmp} = $options{snmp};
69
70 my $oid_version_legacy = '.1.3.6.1.4.1.27975.1.3.5.0';
71 my $oid_version_current = '.1.3.6.1.4.1.52642.1.1.3.5.0';
72 my $snmp_result = $self->{snmp}->get_leef(
73 oids => [$oid_version_legacy, $oid_version_current],
74 nothing_quit => 1
75 );
76 $self->{branch} = '.1.3.6.1.4.1.52642.1';
77 if (!defined($snmp_result->{$oid_version_current})) {
78 $self->{branch} = '.1.3.6.1.4.1.27975';
79 }
80
81 $self->{output}->output_add(long_msg => 'version: ' . $snmp_result->{ $self->{branch} . '.1.3.5.0' });
82 }
83
84 sub get_informations {
85 my ($self, %options) = @_;
86
87 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
88 }
89
90 sub new {
91 my ($class, %options) = @_;
92 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
93 bless $self, $class;
94
95 $options{options}->add_options(arguments => {});
96
97 return $self;
98 }
99
100 1;
101
102 __END__
103
104 =head1 MODE
105
106 Check hardware.
107
108 =over 8
109
110 =item B<--component>
111
112 Which component to check (default: '.*').
113 Can be: 'fan', 'power', 'slot'.
114
115 =item B<--filter>
116
117 Exclude the items given as a comma-separated list (example: --filter=power).
118 You can also exclude items from specific instances: --filter=power,1
119
120 =item B<--no-component>
121
122 Define the expected status if no components are found (default: critical).
123
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,status,regexp).
128 Example: --threshold-overload='fan,CRITICAL,notInstall'
129
130 =item B<--warning>
131
132 Set warning threshold for 'fan.speed' (syntax: type,regexp,threshold)
133 Example: --warning='fan.speed,.*,90'
134
135 =item B<--critical>
136
137 Set critical threshold for 'fan.speed' (syntax: type,regexp,threshold)
138 Example: --critical='fan.speed,.*,95'
139
140 =back
141
142 =cut