| 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 |
package network::cambium::cnpilot::snmp::mode::listradios; |
| 21 |
|
| 22 |
use base qw(centreon::plugins::mode); |
| 23 |
|
| 24 |
use strict; |
| 25 |
use warnings; |
| 26 |
|
| 27 |
sub new { |
| 28 |
my ($class, %options) = @_; |
| 29 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 30 |
bless $self, $class; |
| 31 |
|
| 32 |
$options{options}->add_options(arguments => { |
| 33 |
}); |
| 34 |
|
| 35 |
return $self; |
| 36 |
} |
| 37 |
|
| 38 |
sub check_options { |
| 39 |
my ($self, %options) = @_; |
| 40 |
$self->SUPER::init(%options); |
| 41 |
} |
| 42 |
|
| 43 |
sub manage_selection { |
| 44 |
my ($self, %options) = @_; |
| 45 |
|
| 46 |
# Select relevant oids for discovery function for Radio CnPilot |
| 47 |
my $mapping = { |
| 48 |
cambiumRadioIndex => { oid => '.1.3.6.1.4.1.17713.22.1.2.1.1' }, |
| 49 |
cambiumRadioMACAddress => { oid => '.1.3.6.1.4.1.17713.22.1.2.1.2' }, |
| 50 |
cambiumBandType => { oid => '.1.3.6.1.4.1.17713.22.1.2.1.3' }, |
| 51 |
cambiumRadioState => { oid => '.1.3.6.1.4.1.17713.22.1.2.1.13' }, |
| 52 |
cambiumRadioChannel => { oid => '.1.3.6.1.4.1.17713.22.1.2.1.6' } |
| 53 |
}; |
| 54 |
|
| 55 |
# Point at the begining of the table |
| 56 |
my $oid_cambiumRadioEntry = '.1.3.6.1.4.1.17713.22.1.2.1'; |
| 57 |
|
| 58 |
my $snmp_result = $options{snmp}->get_table( |
| 59 |
oid => $oid_cambiumRadioEntry, |
| 60 |
nothing_quit => 1 |
| 61 |
); |
| 62 |
|
| 63 |
my $results = {}; |
| 64 |
foreach my $oid (keys %{$snmp_result}) { |
| 65 |
next if ($oid !~ /^$mapping->{cambiumRadioMACAddress}->{oid}\.(.*)$/); |
| 66 |
# Catch instance in table |
| 67 |
my $instance = $1; |
| 68 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 69 |
|
| 70 |
$results->{$result->{cambiumRadioMACAddress}} = { |
| 71 |
id => $result->{cambiumRadioIndex}, |
| 72 |
name => $result->{cambiumRadioMACAddress}, |
| 73 |
band_type => $result->{cambiumBandType}, |
| 74 |
transmit_power => $result->{cambiumRadioState}, |
| 75 |
radio_channel => $result->{cambiumRadioChannel} |
| 76 |
}; |
| 77 |
} |
| 78 |
|
| 79 |
return $results; |
| 80 |
} |
| 81 |
|
| 82 |
sub run { |
| 83 |
my ($self, %options) = @_; |
| 84 |
|
| 85 |
my $results = $self->manage_selection(snmp => $options{snmp}); |
| 86 |
foreach my $oid_path (sort keys %$results) { |
| 87 |
$self->{output}->output_add( |
| 88 |
long_msg => sprintf( |
| 89 |
'[id: %s][name: %s][radio channel: %s][transmit power: %s][band type: %s]', |
| 90 |
$results->{$oid_path}->{id}, |
| 91 |
$results->{$oid_path}->{name}, |
| 92 |
$results->{$oid_path}->{radio_channel}, |
| 93 |
$results->{$oid_path}->{transmit_power}, |
| 94 |
$results->{$oid_path}->{band_type} |
| 95 |
) |
| 96 |
); |
| 97 |
} |
| 98 |
|
| 99 |
$self->{output}->output_add( |
| 100 |
severity => 'OK', |
| 101 |
short_msg => 'List Radio' |
| 102 |
); |
| 103 |
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); |
| 104 |
$self->{output}->exit(); |
| 105 |
} |
| 106 |
|
| 107 |
sub disco_format { |
| 108 |
my ($self, %options) = @_; |
| 109 |
|
| 110 |
$self->{output}->add_disco_format(elements => ['id', 'name', 'radio_channel', 'transmit_power', 'band_type']); |
| 111 |
} |
| 112 |
|
| 113 |
sub disco_show { |
| 114 |
my ($self, %options) = @_; |
| 115 |
|
| 116 |
my $results = $self->manage_selection(snmp => $options{snmp}); |
| 117 |
foreach my $oid_path (sort keys %$results) { |
| 118 |
$self->{output}->add_disco_entry( |
| 119 |
id => $results->{$oid_path}->{id}, |
| 120 |
name => $results->{$oid_path}->{name}, |
| 121 |
radio_channel => $results->{$oid_path}->{radio_channel}, |
| 122 |
transmit_power => $results->{$oid_path}->{transmit_power}, |
| 123 |
band_type => $results->{$oid_path}->{band_type} |
| 124 |
); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
1; |
| 129 |
|
| 130 |
__END__ |
| 131 |
|
| 132 |
=head1 MODE |
| 133 |
|
| 134 |
List radio interfaces. |
| 135 |
|
| 136 |
=over 8 |
| 137 |
|
| 138 |
=back |
| 139 |
|
| 140 |
=cut |