Debian Codegraph @

src/network/colubris/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 network::colubris::snmp::mode::load;
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, cb_prefix_output => 'prefix_load_output' }
33 ];
34
35 $self->{maps_counters}->{global} = [
36 { label => '1min', set => {
37 key_values => [ { name => 'load1' } ],
38 output_template => '%s',
39 perfdatas => [
40 { label => 'load1', value => 'load1', template => '%s', min => 0 },
41 ],
42 }
43 },
44 { label => '5min', set => {
45 key_values => [ { name => 'load5' } ],
46 output_template => '%s',
47 perfdatas => [
48 { label => 'load5', value => 'load5', template => '%s', min => 0 },
49 ],
50 }
51 },
52 { label => '15min', set => {
53 key_values => [ { name => 'load15' } ],
54 output_template => '%s',
55 perfdatas => [
56 { label => 'load15', value => 'load15', template => '%s', min => 0 },
57 ],
58 }
59 },
60 ];
61 }
62
63 sub prefix_load_output {
64 my ($self, %options) = @_;
65
66 return "Load average: ";
67 }
68
69 sub new {
70 my ($class, %options) = @_;
71 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
72 bless $self, $class;
73
74 $options{options}->add_options(arguments => {
75 });
76
77 return $self;
78 }
79
80 sub manage_selection {
81 my ($self, %options) = @_;
82
83 my $oid_coUsInfoLoadAverage1Min = '.1.3.6.1.4.1.8744.5.21.1.1.5.0';
84 my $oid_coUsInfoLoadAverage5Min = '.1.3.6.1.4.1.8744.5.21.1.1.6.0';
85 my $oid_coUsInfoLoadAverage15Min = '.1.3.6.1.4.1.8744.5.21.1.1.7.0';
86 my $snmp_result = $options{snmp}->get_leef(
87 oids => [
88 $oid_coUsInfoLoadAverage1Min,
89 $oid_coUsInfoLoadAverage5Min, $oid_coUsInfoLoadAverage15Min
90 ],
91 nothing_quit => 1
92 );
93
94 $self->{global} = {
95 load1 => $snmp_result->{$oid_coUsInfoLoadAverage1Min},
96 load5 => $snmp_result->{$oid_coUsInfoLoadAverage5Min},
97 load15 => $snmp_result->{$oid_coUsInfoLoadAverage15Min},
98 };
99 }
100
101 1;
102
103 __END__
104
105 =head1 MODE
106
107 Check average system load.
108
109 =over 8
110
111 =item B<--filter-counters>
112
113 Only display some counters (regexp can be used).
114 Example: C<--filter-counters='15min'>
115
116 =item B<--warning-1min>
117
118 Thresholds.
119
120 =item B<--critical-1min>
121
122 Thresholds.
123
124 =item B<--warning-5min>
125
126 Thresholds.
127
128 =item B<--critical-5min>
129
130 Thresholds.
131
132 =item B<--warning-15min>
133
134 Thresholds.
135
136 =item B<--critical-15min>
137
138 Thresholds.
139
140 =back
141
142 =cut