Debian Codegraph @

src/os/picos/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 os::picos::snmp::mode::temperature;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub set_counters {
29 my ($self, %options) = @_;
30
31 $self->{maps_counters_type} = [
32 { name => 'global', type => 0 }
33 ];
34
35 $self->{maps_counters}->{global} = [
36 { label => 'switch-temperature', nlabel => 'switch.temperature.celsius', set => {
37 key_values => [ { name => 'switch_temperature' } ],
38 output_template => 'switch temperature: %s C',
39 perfdatas => [
40 { template => '%s', unit => 'C' },
41 ]
42 }
43 },
44 { label => 'chip-temperature', nlabel => 'chip.temperature.celsius', set => {
45 key_values => [ { name => 'chip_temperature' } ],
46 output_template => 'Chip Temperature: %s C',
47 perfdatas => [
48 { template => '%s', unit => 'C' },
49 ],
50 }
51 },
52 { label => 'cpu-temperature', nlabel => 'cpu.temperature.celsius', set => {
53 key_values => [ { name => 'cpu_temperature' } ],
54 output_template => 'CPU Temperature: %s C',
55 perfdatas => [
56 { template => '%s', unit => 'C' },
57 ],
58 }
59 }
60 ];
61 }
62
63 sub new {
64 my ($class, %options) = @_;
65 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
66 bless $self, $class;
67
68 $options{options}->add_options(arguments => {
69 });
70
71 return $self;
72 }
73
74 sub manage_selection {
75 my ($self, %options) = @_;
76
77 my $oid_switchTemperature = '.1.3.6.1.4.1.35098.1.5.0';
78 my $oid_cpuTemperature = '.1.3.6.1.4.1.35098.1.6.0';
79 my $oid_chipTemperature = '.1.3.6.1.4.1.35098.1.7.0';
80
81 my $oids = [$oid_switchTemperature, $oid_chipTemperature, $oid_cpuTemperature];
82 my $snmp_result = $options{snmp}->get_leef(
83 oids => $oids,
84 nothing_quit => 1
85 );
86
87 my $switch_temperature = $snmp_result->{$oid_switchTemperature} =~ s/\s\C.*//r;
88 my $cpu_temperature = $snmp_result->{$oid_cpuTemperature} =~ s/\s\C.*//r;
89 my $chip_temperature = $snmp_result->{$oid_chipTemperature} =~ s/\s\C.*//r;
90
91 $self->{global} = {
92 switch_temperature => $switch_temperature,
93 cpu_temperature => $cpu_temperature,
94 chip_temperature => $chip_temperature
95 };
96 }
97
98 1;
99
100 __END__
101
102 =head1 MODE
103
104 Check temperature.
105
106 =over 8
107
108 =item B<--warning-switch-temperature>
109
110 Warning threshold in celsius degrees for Pica switch.
111
112 =item B<--critical-switch-temperature>
113
114 Critical threshold in celsius degrees for Pica switch.
115
116 =item B<--warning-chip-temperature>
117
118 Warning threshold in celsius degrees for chip.
119
120 =item B<--critical-chip-temperature>
121
122 Critical threshold in celsius degrees for chip.
123
124 =item B<--warning-cpu-temperature>
125
126 Warning threshold in celsius degrees for CPU.
127
128 =item B<--critical-cpu-temperature>
129
130 Critical threshold in celsius degrees for CPU.
131
132 =back
133
134 =cut