Debian Codegraph @

src/network/athonet/epc/snmp/mode/listinterfaceslte.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::listinterfaceslte;
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 $mapping = {
44 name => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.28' }, # iLteHumanName
45 enbid => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.29' } # iLteENBId
46 };
47 my $oid_lteInterfacesEntry = '.1.3.6.1.4.1.35805.10.2.2.99.1';
48
49 sub manage_selection {
50 my ($self, %options) = @_;
51
52 my $snmp_result = $options{snmp}->get_table(
53 oid => $oid_lteInterfacesEntry,
54 start => $mapping->{name}->{oid},
55 end => $mapping->{enbid}->{oid},
56 nothing_quit => 1
57 );
58
59 my $results = {};
60 foreach (keys %$snmp_result) {
61 next if (! /^$mapping->{name}->{oid}\.(.*)$/);
62 my $instance = $1;
63
64 $results->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
65 }
66
67 return $results;
68 }
69
70 sub run {
71 my ($self, %options) = @_;
72
73 my $results = $self->manage_selection(snmp => $options{snmp});
74 foreach my $name (sort keys %$results) {
75 $self->{output}->output_add(long_msg =>
76 join('', map("[$_ = " . $results->{$name}->{$_} . ']', keys(%$mapping)))
77 );
78 }
79
80 $self->{output}->output_add(
81 severity => 'OK',
82 short_msg => 'List lte interfaces:'
83 );
84 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
85 $self->{output}->exit();
86 }
87
88 sub disco_format {
89 my ($self, %options) = @_;
90
91 $self->{output}->add_disco_format(elements => [keys %$mapping]);
92 }
93
94 sub disco_show {
95 my ($self, %options) = @_;
96
97 my $results = $self->manage_selection(snmp => $options{snmp});
98 foreach (sort keys %$results) {
99 $self->{output}->add_disco_entry(
100 %{$results->{$_}}
101 );
102 }
103 }
104
105 1;
106
107 __END__
108
109 =head1 MODE
110
111 List LTE interfaces.
112
113 =over 8
114
115 =back
116
117 =cut