Debian Codegraph @

src/network/mitel/3300icp/snmp/mode/listzaps.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::mitel::3300icp::snmp::mode::listzaps;
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 "filter-name:s" => { name => 'filter_name' },
36 });
37 $self->{zap} = {};
38
39 return $self;
40 }
41
42 sub check_options {
43 my ($self, %options) = @_;
44 $self->SUPER::init(%options);
45 }
46
47 my $mapping = {
48 mitelBWMCurrentZAPLabel => { oid => '.1.3.6.1.4.1.1027.4.1.1.2.5.1.1.1.1.4' },
49 };
50
51 sub manage_selection {
52 my ($self, %options) = @_;
53
54 my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{mitelBWMCurrentZAPLabel}->{oid} },
55 ],
56 return_type => 1, nothing_quit => 1);
57 foreach my $oid (keys %$snmp_result) {
58 next if ($oid !~ /^$mapping->{mitelBWMCurrentZAPLabel}->{oid}\.(.*)$/);
59 my $instance = $1;
60 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
61
62 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
63 $result->{mitelBWMCurrentZAPLabel} !~ /$self->{option_results}->{filter_name}/) {
64 $self->{output}->output_add(long_msg => "skipping '" . $result->{mitelBWMCurrentZAPLabel} . "': no matching filter.", debug => 1);
65 next;
66 }
67
68 $self->{zap}->{$instance} = {
69 name => $result->{mitelBWMCurrentZAPLabel},
70 };
71 }
72 }
73
74 sub run {
75 my ($self, %options) = @_;
76
77 $self->manage_selection(%options);
78 foreach my $instance (sort keys %{$self->{zap}}) {
79 $self->{output}->output_add(long_msg => '[name = ' . $self->{zap}->{$instance}->{name} . "]"
80 );
81 }
82
83 $self->{output}->output_add(severity => 'OK',
84 short_msg => 'List zone access points:');
85 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
86 $self->{output}->exit();
87 }
88
89 sub disco_format {
90 my ($self, %options) = @_;
91
92 $self->{output}->add_disco_format(elements => ['name']);
93 }
94
95 sub disco_show {
96 my ($self, %options) = @_;
97
98 $self->manage_selection(%options);
99 foreach my $instance (sort keys %{$self->{zap}}) {
100 $self->{output}->add_disco_entry(
101 name => $self->{zap}->{$instance}->{name}
102 );
103 }
104 }
105
106 1;
107
108 __END__
109
110 =head1 MODE
111
112 List zone access points.
113
114 =over 8
115
116 =item B<--filter-name>
117
118 Filter by zone access points name (can be a regexp).
119
120 =back
121
122 =cut
123