Debian Codegraph @

src/network/athonet/epc/snmp/mode/aggregate.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::athonet::epc::snmp::mode::aggregate;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub set_counters {
30 my ($self, %options) = @_;
31
32 $self->{maps_counters_type} = [
33 { name => 'global', type => 0, skipped_code => { -10 => 1 } }
34 ];
35
36 $self->{maps_counters}->{global} = [
37 { label => 'traffic-in', nlabel => 'aggregate.traffic.in.bytespersecond', set => {
38 key_values => [ { name => 'traffic_in', per_second => 1 } ],
39 output_template => 'traffic in: %.2f %s/s',
40 output_change_bytes => 1,
41 perfdatas => [
42 { template => '%s', unit => 'B/s', min => 0 }
43 ]
44 }
45 },
46 { label => 'traffic-out', nlabel => 'aggregate.traffic.out.bytespersecond', set => {
47 key_values => [ { name => 'traffic_out', per_second => 1 } ],
48 output_template => 'traffic out: %.2f %s/s',
49 output_change_bytes => 1,
50 perfdatas => [
51 { template => '%s', unit => 'B/s', min => 0 }
52 ]
53 }
54 },
55 { label => 'users-roaming-connected', nlabel => 'hss.users.roaming.connected.count', set => {
56 key_values => [ { name => 'roaming_users' } ],
57 output_template => 'roaming users connected: %s',
58 perfdatas => [
59 { template => '%s', min => 0 }
60 ]
61 }
62 },
63 { label => 'requests-authentication', nlabel => 'hss.requests.authentication.count', set => {
64 key_values => [ { name => 'auth_req', diff => 1 } ],
65 output_template => 'number of authentication requests: %s',
66 perfdatas => [
67 { template => '%s', min => 0 }
68 ]
69 }
70 },
71 { label => 'location-updates', nlabel => 'hss.location.updates.count', set => {
72 key_values => [ { name => 'location_updates', diff => 1 } ],
73 output_template => 'number of location updates: %s',
74 perfdatas => [
75 { template => '%s', min => 0 }
76 ]
77 }
78 }
79 ];
80 }
81
82 sub new {
83 my ($class, %options) = @_;
84 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
85 bless $self, $class;
86
87 $options{options}->add_options(arguments => {
88 });
89
90 return $self;
91 }
92
93 my $mapping = {
94 traffic_in => { oid => '.1.3.6.1.4.1.35805.10.2.99.5' }, # loadPktInGi
95 traffic_out => { oid => '.1.3.6.1.4.1.35805.10.2.99.6' }, # loadPktOutGi
96 roaming_users => { oid => '.1.3.6.1.4.1.35805.10.2.99.8' }, # hssRoamingUsers
97 auth_req => { oid => '.1.3.6.1.4.1.35805.10.2.99.9' }, # hssAuthenticationRequests
98 location_updates => { oid => '.1.3.6.1.4.1.35805.10.2.99.10' } # hssLocationUpdates
99 };
100
101 sub manage_selection {
102 my ($self, %options) = @_;
103
104 $self->{cache_name} = 'athonet_epc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
105 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
106 my $snmp_result = $options{snmp}->get_leef(
107 oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
108 nothing_quit => 1
109 );
110 $self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
111 }
112
113 1;
114
115 __END__
116
117 =head1 MODE
118
119 Check aggregate statistics.
120
121 =over 8
122
123 =item B<--filter-counters>
124
125 Only display some counters (regexp can be used).
126 Example: --filter-counters='roaming'
127
128 =item B<--warning-*> B<--critical-*>
129
130 Thresholds.
131 Can be: 'traffic-in', 'traffic-out',
132 'users-roaming-connected', 'requests-authentication', 'location-updates'.
133
134 =back
135
136 =cut