Debian Codegraph @

src/network/juniper/trapeze/snmp/mode/cpu.pm

raw
1 #
2 # Copyright 2015 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::juniper::trapeze::snmp::mode::cpu;
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 => 'cpu', type => 0, cb_prefix_output => 'prefix_cpu_output' }
33 ];
34
35 $self->{maps_counters}->{cpu} = [
36 { label => 'average', set => {
37 key_values => [ { name => 'trpzSysCpuAverageLoad' } ],
38 output_template => 'average : %.2f %%',
39 perfdatas => [
40 { label => 'cpu_average', value => 'trpzSysCpuAverageLoad', template => '%.2f',
41 min => 0, max => 100, unit => '%' },
42 ],
43 }
44 },
45 { label => '1m', set => {
46 key_values => [ { name => 'trpzSysCpuLastMinuteLoad' } ],
47 output_template => '1 minute : %.2f %%',
48 perfdatas => [
49 { label => 'cpu_1m', value => 'trpzSysCpuLastMinuteLoad', template => '%.2f',
50 min => 0, max => 100, unit => '%' },
51 ],
52 }
53 },
54 { label => '5m', set => {
55 key_values => [ { name => 'trpzSysCpuLast5MinutesLoad' } ],
56 output_template => '5 minutes : %.2f %%',
57 perfdatas => [
58 { label => 'cpu_5m', value => 'trpzSysCpuLast5MinutesLoad', template => '%.2f',
59 min => 0, max => 100, unit => '%' },
60 ],
61 }
62 },
63 { label => '1h', set => {
64 key_values => [ { name => ' trpzSysCpuLastHourLoad' } ],
65 output_template => '1 hour : %.2f %%',
66 perfdatas => [
67 { label => 'cpu_1h', value => ' trpzSysCpuLastHourLoad', template => '%.2f',
68 min => 0, max => 100, unit => '%' },
69 ],
70 }
71 },
72 ];
73 }
74
75 sub prefix_cpu_output {
76 my ($self, %options) = @_;
77
78 return "CPU Usage ";
79 }
80
81 sub new {
82 my ($class, %options) = @_;
83 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
84 bless $self, $class;
85
86 $options{options}->add_options(arguments =>
87 {
88 });
89
90 return $self;
91 }
92
93 sub manage_selection {
94 my ($self, %options) = @_;
95
96 # TRAPEZE-NETWORKS-SYSTEM-MIB
97 my $oid_trpzSysCpuAverageLoad = '.1.3.6.1.4.1.14525.4.8.1.1.5.0';
98 my $oid_trpzSysCpuLastMinuteLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.2.0';
99 my $oid_trpzSysCpuLast5MinutesLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.3.0';
100 my $oid_trpzSysCpuLastHourLoad = '.1.3.6.1.4.1.14525.4.8.1.1.11.4.0';
101
102 my $results = $options{snmp}->get_leef(oids => [$oid_trpzSysCpuAverageLoad, $oid_trpzSysCpuLastMinuteLoad,
103 $oid_trpzSysCpuLast5MinutesLoad, $oid_trpzSysCpuLastHourLoad ],
104 nothing_quit => 1);
105
106 $self->{cpu} = { trpzSysCpuAverageLoad => $results->{$oid_trpzSysCpuAverageLoad},
107 trpzSysCpuLastMinuteLoad => $results->{$oid_trpzSysCpuLastMinuteLoad},
108 trpzSysCpuLast5MinutesLoad => $results->{$oid_trpzSysCpuLast5MinutesLoad},
109 trpzSysCpuLastHourLoad => $results->{$oid_trpzSysCpuLastHourLoad},
110 };
111 }
112
113 1;
114
115 __END__
116
117 =head1 MODE
118
119 Check CPU usage
120
121 =over 8
122
123 =item B<--filter-counters>
124
125 Only display some counters (regexp can be used).
126 Example: --filter-counters='^(1m|5m)$'
127
128 =item B<--warning-*>
129
130 Warning threshold.
131 Can be: '1m', '5m', '1h, 'average'
132
133 =item B<--critical-*>
134
135 Critical threshold.
136 Can be: '1m', '5m', '1h', 'average'
137
138 =back
139
140 =cut