Debian Codegraph @

src/hardware/sensors/rittal/cmc3/snmp/mode/load.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::rittal::cmc3::snmp::mode::load;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub prefix_output {
29 my ($self, %options) = @_;
30
31 return 'system load ';
32 }
33
34 sub set_counters {
35 my ($self, %options) = @_;
36
37 $self->{maps_counters_type} = [
38 { name => 'unit_load', type => 0, cb_prefix_output => 'prefix_output' }
39 ];
40
41 $self->{maps_counters}->{unit_load} = [
42 {
43 label => 'unit-load-1m', nlabel => 'system.load.1m.percentage',
44 set => {
45 key_values => [ { name => 'load1' } ],
46 output_template => '%.2f (1m)',
47 perfdatas => [
48 { template => '%.2f', min => 0, max => 100, unit => '%' }
49 ]
50 }
51 },
52 {
53 label => 'unit-load-5m', nlabel => 'system.load.5m.percentage',
54 set => {
55 key_values => [ { name => 'load5' } ],
56 output_template => '%.2f (5m)',
57 perfdatas => [
58 { template => '%.2f', min => 0, max => 100, unit => '%' }
59 ]
60 }
61 },
62 {
63 label => 'unit-load-10m', nlabel => 'system.load.10m.percentage',
64 set => {
65 key_values => [ { name => 'load10' } ],
66 output_template => '%.2f (10m)',
67 perfdatas => [
68 { template => '%.2f', min => 0, max => 100, unit => '%' }
69 ]
70 }
71 },
72 ];
73 }
74
75 sub new {
76 my ($class, %options) = @_;
77 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
78 bless $self, $class;
79
80 $options{options}->add_options(arguments => {});
81
82 return $self;
83 }
84
85 my $mapping = {
86 unit_load => { oid => '.1.3.6.1.4.1.2606.7.2.14.1.2' }
87 };
88
89 sub manage_selection {
90 my ($self, %options) = @_;
91
92 my $oid_cmcIIIUnitLoadEntry = '.1.3.6.1.4.1.2606.7.2.14.1';
93 my $results = $options{snmp}->get_table(
94 oid => $oid_cmcIIIUnitLoadEntry,
95 nothing_quit => 1
96 );
97
98 $self->{unit_load} = {};
99 foreach (keys %$results) {
100 next if (!/^$mapping->{unit_load}->{oid}\.(\d+)$/);
101 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $1);
102 $self->{unit_load}->{'load' . $1} = $result->{unit_load} / 100;
103 }
104 }
105
106 1;
107
108 __END__
109
110 =head1 MODE
111
112 Check unit load
113
114 =over 8
115
116 =item B<--warning-*> B<--critical-*>
117
118 Load threshold in %.
119
120 Thresholds: unit-load-1m, unit-load-5m, unit-load-10m
121
122 =back
123
124 =cut