| 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::mikrotik::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 |
'oid-filter:s' => { name => 'oid_filter', default => 'ifname' }, |
| 35 |
'oid-display:s' => { name => 'oid_display', default => 'ifname' } |
| 36 |
}); |
| 37 |
|
| 38 |
$self->{oids_label} = { |
| 39 |
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2', |
| 40 |
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18', |
| 41 |
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1' |
| 42 |
}; |
| 43 |
|
| 44 |
return $self; |
| 45 |
} |
| 46 |
|
| 47 |
sub check_options { |
| 48 |
my ($self, %options) = @_; |
| 49 |
$self->SUPER::init(%options); |
| 50 |
} |
| 51 |
|
| 52 |
sub run { |
| 53 |
my ($self, %options) = @_; |
| 54 |
|
| 55 |
my $oids = [{ oid => $self->{oids_label}->{'ifname'} }]; |
| 56 |
$self->{snmp} = $options{snmp}; |
| 57 |
my $interfaceTables = $self->{snmp}->get_multiple_table(oids => $oids); |
| 58 |
|
| 59 |
foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$interfaceTables->{ $self->{oids_label}->{'ifname'} }})) { |
| 60 |
next if ($key !~ /^$self->{oids_label}->{'ifname'}\.(.*)$/); |
| 61 |
$self->{datas}->{'ifname' . "_" . $1} = $self->{output}->decode($interfaceTables->{$self->{oids_label}->{'ifname'} }->{$key}); |
| 62 |
push @{$self->{datas}->{all_ids}}, $1; |
| 63 |
} |
| 64 |
|
| 65 |
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) { |
| 66 |
$self->{output}->add_option_msg(short_msg => "Can't get interfaces..."); |
| 67 |
$self->{output}->option_exit(); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
if (scalar(@{$self->{datas}->{all_ids}}) <= 0) { |
| 72 |
$self->{output}->add_option_msg(short_msg => "No entry found"); |
| 73 |
$self->{output}->option_exit(); |
| 74 |
} |
| 75 |
|
| 76 |
my $mktFrequenOid = '.1.3.6.1.4.1.14988.1.1.1.3.1.4.'; |
| 77 |
|
| 78 |
foreach (sort @{$self->{datas}->{all_ids}}) { |
| 79 |
my $display_value = $self->get_display_value(id => $_); |
| 80 |
my $oid = $mktFrequenOid . $_; |
| 81 |
my $snmp_result = $options{snmp}->get_leef(oids => [$oid]); |
| 82 |
if (defined($snmp_result->{$oid})){ |
| 83 |
$self->{output}->output_add(long_msg => $display_value . " : " . $snmp_result->{$oid}); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
$self->{output}->output_add(severity => 'OK', |
| 88 |
short_msg => 'SSIDs:'); |
| 89 |
|
| 90 |
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); |
| 91 |
$self->{output}->exit(); |
| 92 |
} |
| 93 |
|
| 94 |
sub get_display_value { |
| 95 |
my ($self, %options) = @_; |
| 96 |
|
| 97 |
my $value = $self->{datas}->{"ifname_" . $options{id}}; |
| 98 |
return $value; |
| 99 |
} |
| 100 |
|
| 101 |
1; |
| 102 |
|
| 103 |
__END__ |
| 104 |
|
| 105 |
=head1 MODE |
| 106 |
|
| 107 |
List SSIDs for each interface. |
| 108 |
|
| 109 |
=over 8 |
| 110 |
|
| 111 |
=cut |