Debian Codegraph @

src/network/ruckus/scg/snmp/mode/listssids.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::ruckus::scg::snmp::mode::listssids;
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->{ssid} = {};
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 ruckusSCGWLANSSID => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.1' },
49 ruckusSCGWLANZone => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.2' },
50 ruckusSCGWLANDomain => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.3' },
51 ruckusSCGWLANAuthType => { oid => '.1.3.6.1.4.1.25053.1.3.2.1.1.1.2.1.17' },
52 };
53
54 sub manage_selection {
55 my ($self, %options) = @_;
56
57 my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{ruckusSCGWLANSSID}->{oid} },
58 { oid => $mapping->{ruckusSCGWLANZone}->{oid} },
59 { oid => $mapping->{ruckusSCGWLANDomain}->{oid} },
60 { oid => $mapping->{ruckusSCGWLANAuthType}->{oid} },
61 ],
62 return_type => 1, nothing_quit => 1);
63 foreach my $oid (keys %$snmp_result) {
64 next if ($oid !~ /^$mapping->{ruckusSCGWLANSSID}->{oid}\.(.*)$/);
65 my $instance = $1;
66 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
67
68 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
69 $result->{ruckusSCGWLANSSID} !~ /$self->{option_results}->{filter_name}/) {
70 $self->{output}->output_add(long_msg => "skipping '" . $result->{ruckusSCGWLANSSID} . "': no matching filter.", debug => 1);
71 next;
72 }
73
74 $self->{ssid}->{$instance} = {
75 name => $result->{ruckusSCGWLANSSID},
76 zone => $result->{ruckusSCGWLANZone},
77 domain => $result->{ruckusSCGWLANDomain},
78 authentication => $result->{ruckusSCGWLANAuthType}
79 };
80 }
81 }
82
83 sub run {
84 my ($self, %options) = @_;
85
86 $self->manage_selection(%options);
87 foreach my $instance (sort keys %{$self->{ssid}}) {
88 $self->{output}->output_add(long_msg => '[name = ' . $self->{ssid}->{$instance}->{name} .
89 "] [zone = " . $self->{ssid}->{$instance}->{zone} .
90 "] [domain = " . $self->{ssid}->{$instance}->{domain} .
91 "] [authentication = " . $self->{ssid}->{$instance}->{authentication} . "]"
92 );
93 }
94
95 $self->{output}->output_add(severity => 'OK',
96 short_msg => 'List SSIDs:');
97 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
98 $self->{output}->exit();
99 }
100
101 sub disco_format {
102 my ($self, %options) = @_;
103
104 $self->{output}->add_disco_format(elements => ['name', 'zone', 'domain', 'authentication']);
105 }
106
107 sub disco_show {
108 my ($self, %options) = @_;
109
110 $self->manage_selection(%options);
111 foreach my $instance (sort keys %{$self->{ssid}}) {
112 $self->{output}->add_disco_entry(
113 name => $self->{ssid}->{$instance}->{name},
114 zone => $self->{ssid}->{$instance}->{zone},
115 domain => $self->{ssid}->{$instance}->{domain},
116 authentication => $self->{ssid}->{$instance}->{authentication});
117 }
118 }
119
120 1;
121
122 __END__
123
124 =head1 MODE
125
126 List SSIDs.
127
128 =over 8
129
130 =item B<--filter-name>
131
132 Filter by SSID name (can be a regexp).
133
134 =back
135
136 =cut
137