Debian Codegraph @

src/storage/synology/snmp/mode/temperature.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::temperature;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub custom_temp_perfdata {
29 my ($self, %options) = @_;
30
31 $self->{output}->perfdata_add(
32 nlabel => $self->{nlabel},
33 unit => 'C',
34 instances => 'system',
35 value => $self->{result_values}->{temperature},
36 warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
37 critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
38 );
39 }
40
41 sub set_counters {
42 my ($self, %options) = @_;
43
44 $self->{maps_counters_type} = [
45 { name => 'global', type => 0 }
46 ];
47
48 $self->{maps_counters}->{global} = [
49 { label => 'temperature', nlabel => 'hardware.temperature.celsius', set => {
50 key_values => [ { name => 'temperature' } ],
51 output_template => 'system temperature: %s C',
52 closure_custom_perfdata => $self->can('custom_temp_perfdata')
53 }
54 }
55 ];
56 }
57
58 sub new {
59 my ($class, %options) = @_;
60 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
61 bless $self, $class;
62
63 $options{options}->add_options(arguments => {
64 });
65
66 return $self;
67 }
68
69 sub manage_selection {
70 my ($self, %options) = @_;
71
72 my $oid_synoSystemtemperature = '.1.3.6.1.4.1.6574.1.2.0'; # in Celsius
73
74 my $snmp_result = $options{snmp}->get_leef(
75 oids => [ $oid_synoSystemtemperature ],
76 nothing_quit => 1
77 );
78
79 $self->{global} = {
80 temperature => $snmp_result->{$oid_synoSystemtemperature}
81 };
82 }
83
84 1;
85
86 __END__
87
88 =head1 MODE
89
90 Check temperature (SYNOLOGY-SYSTEM-MIB).
91
92 =over 8
93
94 =item B<--warning-temperature>
95
96 Warning threshold in celsius degrees.
97
98 =item B<--critical-temperature>
99
100 Critical threshold in celsius degrees.
101
102 =back
103
104 =cut