Debian Codegraph @

src/network/athonet/epc/snmp/mode/listinterfacesgtpc.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::listinterfacesgtpc;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 sub new {
29 my ($class, %options) = @_;
30 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
31 bless $self, $class;
32
33 $options{options}->add_options(arguments => {
34 });
35 return $self;
36 }
37
38 sub check_options {
39 my ($self, %options) = @_;
40 $self->SUPER::init(%options);
41 }
42
43 my $map_status = { 0 => 'down', 1 => 'up' };
44 my $map_type = { 1 => 'gTPv1', 2 => 'gTPv2', 11 => 'gTPPrime' };
45 my $map_owner = {
46 0 => 'unknown', 1 => 'mme', 2 => 'msc', 3 => 'sgsn',
47 4 => 'fgw', 5 => 'wifi', 6 => 'sgw', 7 => 'pgw', 8 => 'hlr-hss'
48 };
49
50 my $mapping = {
51 source_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.1' }, # gTPcAddressSource
52 destination_address => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.3' }, # gTPcAddressDestination
53 type => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.5', map => $map_type }, # gTPcGTPType
54 status => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.6', map => $map_status }, # gTPcState
55 owner => { oid => '.1.3.6.1.4.1.35805.10.2.12.9.1.8', map => $map_owner } # gTPcOwner
56 };
57 my $oid_gtpcInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.12.9.1';
58
59 sub manage_selection {
60 my ($self, %options) = @_;
61
62 my $snmp_result = $options{snmp}->get_table(
63 oid => $oid_gtpcInterfacesEntry,
64 end => $mapping->{owner}->{oid},
65 nothing_quit => 1
66 );
67
68 my $results = {};
69 foreach (keys %$snmp_result) {
70 next if (! /^$mapping->{source_address}->{oid}\.(.*)$/);
71 my $instance = $1;
72
73 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
74 $results->{$instance} = $result;
75 }
76
77 return $results;
78 }
79
80 sub run {
81 my ($self, %options) = @_;
82
83 my $results = $self->manage_selection(snmp => $options{snmp});
84 foreach my $name (sort keys %$results) {
85 $self->{output}->output_add(long_msg =>
86 join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping)))
87 );
88 }
89
90 $self->{output}->output_add(
91 severity => 'OK',
92 short_msg => 'List gtp control interfaces:'
93 );
94 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
95 $self->{output}->exit();
96 }
97
98 sub disco_format {
99 my ($self, %options) = @_;
100
101 $self->{output}->add_disco_format(elements => [keys %$mapping]);
102 }
103
104 sub disco_show {
105 my ($self, %options) = @_;
106
107 my $results = $self->manage_selection(snmp => $options{snmp});
108 foreach (sort keys %$results) {
109 $self->{output}->add_disco_entry(
110 %{$results->{$_}}
111 );
112 }
113 }
114
115 1;
116
117 __END__
118
119 =head1 MODE
120
121 List GTP control interfaces.
122
123 =over 8
124
125 =back
126
127 =cut