Debian Codegraph @

src/network/hirschmann/standard/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::hirschmann::standard::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} = '^(?:temperature)$';
32
33 $self->{cb_hook2} = 'snmp_execute';
34
35 $self->{thresholds} = {
36 fan => [
37 #hios
38 ['not-available', 'OK'],
39 ['available-and-ok', 'OK'],
40 ['available-but-failure', 'CRITICAL'],
41
42 # classic
43 ['ok', 'OK'],
44 ['failed', 'CRITICAL']
45 ],
46 psu => [
47 # classic
48 ['ok', 'OK'],
49 ['failed', 'CRITICAL'],
50 ['notInstalled', 'OK'],
51 ['unknown', 'UNKNOWN'],
52 ['ignore', 'OK'],
53
54 # hios
55 ['present', 'OK'],
56 ['defective', 'CRITICAL']
57 ],
58 led => [
59 ['off', 'OK'],
60 ['green', 'OK'],
61 ['yellow', 'WARNING'],
62 ['red', 'CRITICAL']
63 ]
64 };
65
66 $self->{myrequest} = {
67 classic => [],
68 hios => []
69 };
70
71 $self->{components_path} = 'network::hirschmann::standard::snmp::mode::components';
72 $self->{components_module} = ['fan', 'led', 'psu', 'temperature'];
73 }
74
75 sub snmp_execute {
76 my ($self, %options) = @_;
77
78 $self->{snmp} = $options{snmp};
79
80 my $hios_serial = '.1.3.6.1.4.1.248.11.10.1.1.3.0'; # hm2DevMgmtSerialNumber
81 my $classic_version = '.1.3.6.1.4.1.248.14.1.1.2.0'; # hmSysVersion
82 my $snmp_result = $self->{snmp}->get_leef(
83 oids => [ $hios_serial, $classic_version ],
84 nothing_quit => 1
85 );
86
87 $self->{os_type} = 'unknown';
88 $self->{results} = {};
89 if (defined($snmp_result->{$classic_version})) {
90 $self->{os_type} = 'classic';
91 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{myrequest}->{classic});
92 } elsif ($snmp_result->{$hios_serial}) {
93 $self->{os_type} = 'hios';
94 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{myrequest}->{hios});
95 }
96 }
97
98 sub new {
99 my ($class, %options) = @_;
100 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
101 bless $self, $class;
102
103 $options{options}->add_options(arguments => {});
104
105 return $self;
106 }
107
108 1;
109
110 __END__
111
112 =head1 MODE
113
114 Check hardware.
115
116 =over 8
117
118 =item B<--component>
119
120 Which component to check (default: '.*').
121 Can be: 'fan', 'psu', 'temperature', 'led'.
122
123 =item B<--filter>
124
125 Exclude the items given as a comma-separated list (example: --filter=fan).
126 You can also exclude items from specific instances: --filter=fan,1.1
127
128 =item B<--absent-problem>
129
130 Return an error if an entity is not 'present' (default is skipping) (comma separated list)
131 Can be specific or global: --absent-problem=psu,1.1
132
133 =item B<--no-component>
134
135 Define the expected status if no components are found (default: critical).
136
137
138 =item B<--threshold-overload>
139
140 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
141 Example: --threshold-overload='psu,CRITICAL,^(?!(ok)$)'
142
143 =item B<--warning>
144
145 Set warning threshold for temperatures (syntax: type,regexp,threshold)
146 Example: --warning='temperature,.*,30'
147
148 =item B<--critical>
149
150 Set critical threshold for temperatures (syntax: type,regexp,threshold)
151 Example: --critical='temperature,.*,40'
152
153 =back
154
155 =cut