Debian Codegraph @

src/hardware/sensors/netbotz/snmp/mode/sensors.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 hardware::sensors::netbotz::snmp::mode::sensors;
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|humidity|dewpoint|airflow)$';
32
33 $self->{cb_hook1} = 'get_version';
34 $self->{cb_hook2} = 'snmp_execute';
35
36 $self->{thresholds} = {
37 default => [
38 ['normal', 'OK'],
39 ['info', 'OK'],
40 ['warning', 'WARNING'],
41 ['error', 'CRITICAL'],
42 ['critical', 'CRITICAL'],
43 ['failure', 'CRITICAL']
44 ]
45 };
46
47 $self->{components_path} = 'hardware::sensors::netbotz::snmp::mode::components';
48 $self->{components_module} = [
49 'temperature', 'humidity', 'dewpoint', 'airflow',
50 'doorswitch', 'camera', 'otherstate'
51 ];
52 }
53
54 sub get_version {
55 my ($self, %options) = @_;
56
57 my $v1_netBotzErrorStatus = '.1.3.6.1.4.1.5528.100.100';
58 my $v5_netBotzErrorStatus = '.1.3.6.1.4.1.52674.500.100.0';
59 my $result = $options{snmp}->get_leef(
60 oids => [$v1_netBotzErrorStatus, $v1_netBotzErrorStatus . '.0', $v5_netBotzErrorStatus]
61 );
62
63 $self->{is_v5} = 0;
64 $self->{netbotz_branch} = '5528.100';
65 if (defined($result->{$v5_netBotzErrorStatus})) {
66 $self->{is_v5} = 1;
67 $self->{netbotz_branch} = '52674.500';
68 } elsif (!defined($result->{$v1_netBotzErrorStatus}) && !defined($result->{$v1_netBotzErrorStatus . '.0'})) {
69 $self->{output}->add_option_msg(short_msg => 'cannot find netbotz version');
70 $self->{output}->option_exit();
71 }
72 }
73
74 sub snmp_execute {
75 my ($self, %options) = @_;
76
77 $self->{snmp} = $options{snmp};
78 $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
79 }
80
81 sub new {
82 my ($class, %options) = @_;
83 my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
84 bless $self, $class;
85
86 $options{options}->add_options(arguments => {});
87
88 return $self;
89 }
90
91 1;
92
93 __END__
94
95 =head1 MODE
96
97 Check sensors.
98
99 =over 8
100
101 =item B<--component>
102
103 Which component to check (default: '.*').
104 Can be: 'temperature', 'humidity', 'dewpoint', 'airflow',
105 'doorswitch', 'camera', 'otherstate'.
106
107 =item B<--filter>
108
109 Exclude the items given as a comma-separated list (example: --filter=temperature --filter=humidity).
110 You can also exclude items from specific instances: --filter=temperature,1
111
112 =item B<--no-component>
113
114 Define the expected status if no components are found (default: critical).
115
116 =item B<--threshold-overload>
117
118 Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp).
119 Example: --threshold-overload='temperature,CRITICAL,^(?!(normal)$)'
120
121 =item B<--warning>
122
123 Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
124 Example: --warning='temperature,.*,30'
125
126 =item B<--critical>
127
128 Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
129 Example: --warning='temperature,.*,50'
130
131 =back
132
133 =cut