Add ubiquiti airfiber snmp (#2592)
This commit is contained in:
parent
47d5e4ab4d
commit
5f0871b819
|
@ -0,0 +1,121 @@
|
||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and alarm monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package centreon::common::frogfoot::snmp::mode::load;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub prefix_load_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Load average ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'loadaverage', type => 0, cb_prefix_output => 'prefix_load_output', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{loadaverage} = [
|
||||||
|
{ label => 'load1', nlabel => 'system.loadaverage.1m.count', set => {
|
||||||
|
key_values => [ { name => 'load1' } ],
|
||||||
|
output_template => '%.2f (1m)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'load5', nlabel => 'system.loadaverage.5m.count', set => {
|
||||||
|
key_values => [ { name => 'load5' } ],
|
||||||
|
output_template => '%.2f (5m)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'load15', nlabel => 'system.loadaverage.15m.count', set => {
|
||||||
|
key_values => [ { name => 'load15' } ],
|
||||||
|
output_template => '%.2f (15m)',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
load_descr => { oid => '.1.3.6.1.4.1.10002.1.1.1.4.2.1.2' }, # loadDescr
|
||||||
|
load_value => { oid => '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3' } # loadValue
|
||||||
|
};
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_load_entry = '.1.3.6.1.4.1.10002.1.1.1.4.2.1'; # loadEntry
|
||||||
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
|
oid => $oid_load_entry,
|
||||||
|
start => $mapping->{load_descr}->{oid},
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{loadaverage} = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
next if (! /^$mapping->{load_descr}->{oid}\.(\d+)$/);
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1);
|
||||||
|
if ($result->{load_descr} =~ /(\d+)/) {
|
||||||
|
$self->{loadaverage}->{'load' . $1} = $result->{load_value};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check the load average.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds where '*' can be: load1, load5, load15
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,120 @@
|
||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package centreon::common::frogfoot::snmp::mode::memory;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub custom_usage_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'Memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)',
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{total}),
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{used}),
|
||||||
|
$self->{result_values}->{prct_used},
|
||||||
|
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free}),
|
||||||
|
$self->{result_values}->{prct_free}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'memory', type => 0, skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{memory} = [
|
||||||
|
{ label => 'usage', nlabel => 'memory.usage.bytes', set => {
|
||||||
|
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => {
|
||||||
|
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_memTotal = '.1.3.6.1.4.1.10002.1.1.1.1.1.0'; # KB
|
||||||
|
my $oid_memFree = '.1.3.6.1.4.1.10002.1.1.1.1.2.0'; # KB
|
||||||
|
my $result = $options{snmp}->get_leef(oids => [$oid_memTotal, $oid_memFree], nothing_quit => 1);
|
||||||
|
|
||||||
|
my $free = $result->{$oid_memFree} * 1024;
|
||||||
|
my $total = $result->{$oid_memTotal} * 1024;
|
||||||
|
my $prct_used = ($total - $free) * 100 / $total;
|
||||||
|
$self->{memory} = {
|
||||||
|
total => $total,
|
||||||
|
used => $total - $free,
|
||||||
|
free => $free,
|
||||||
|
prct_used => $prct_used,
|
||||||
|
prct_free => 100 - $prct_used
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check memory usage.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -44,7 +44,7 @@ sub rp_long_output {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_tenant_output {
|
sub prefix_rp_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
|
@ -212,7 +212,7 @@ Can used special variables like: %{status}, %{uid}
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'space-usage-prct', 'space-usage', 'space-usage-free'.
|
Can be: 'cpu-utilization', 'memory-usage', 'requests'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package network::ubiquiti::airfiber::snmp::mode::listradios;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $map_state = { 0 => 'down', 1 => 'up' };
|
||||||
|
my $map_enabled = { 1 => 'yes', 2 => 'no' };
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
enabled => { oid => '.1.3.6.1.4.1.41112.1.3.1.1.2', map => $map_enabled }, # radioEnable
|
||||||
|
state => { oid => '.1.3.6.1.4.1.41112.1.3.2.1.26', map => $map_state } # radioLinkState
|
||||||
|
};
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_name = '.1.3.6.1.4.1.41112.1.3.1.1.14'; # linkName
|
||||||
|
my $snmp_result = $options{snmp}->get_table(oid => $oid_name);
|
||||||
|
my $results = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
/\.(\d+)$/;
|
||||||
|
|
||||||
|
$results->{$1} = { name => $snmp_result->{$_} };
|
||||||
|
}
|
||||||
|
|
||||||
|
$options{snmp}->load(
|
||||||
|
oids => [ map($_->{oid}, values(%$mapping)) ],
|
||||||
|
instances => [ map($_, keys(%$results)) ],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef();
|
||||||
|
foreach (keys %$results) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
|
||||||
|
|
||||||
|
$results->{$_} = { %$result, %{$results->{$_}} };
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
|
foreach my $instance (sort keys %$results) {
|
||||||
|
$self->{output}->output_add(long_msg =>
|
||||||
|
join('', map("[$_ = " . $results->{$instance}->{$_} . ']', ('name', keys(%$mapping))))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => 'List radio interfaces:'
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_format {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{output}->add_disco_format(elements => ['name', keys %$mapping]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_show {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $results = $self->manage_selection(snmp => $options{snmp});
|
||||||
|
foreach (sort keys %$results) {
|
||||||
|
$self->{output}->add_disco_entry(
|
||||||
|
%{$results->{$_}}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
List radio interfaces.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,244 @@
|
||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package network::ubiquiti::airfiber::snmp::mode::radios;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'state: %s [enabled: %s]',
|
||||||
|
$self->{result_values}->{state},
|
||||||
|
$self->{result_values}->{enabled}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub radio_long_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"checking radio interface '%s'",
|
||||||
|
$options{instance_value}->{name}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_radio_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"radio interface '%s' ",
|
||||||
|
$options{instance_value}->{name}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_signal_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'signal ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_traffic_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'traffic ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'radios', type => 3, cb_prefix_output => 'prefix_radio_output', cb_long_output => 'radio_long_output',
|
||||||
|
indent_long_output => ' ', message_multiple => 'All radio interfaces are ok',
|
||||||
|
group => [
|
||||||
|
{ name => 'status', type => 0, skipped_code => { -10 => 1 } },
|
||||||
|
{ name => 'signal', type => 0, cb_prefix_output => 'prefix_signal_output', skipped_code => { -10 => 1 } },
|
||||||
|
{ name => 'traffic', type => 0, cb_prefix_output => 'prefix_traffic_output', skipped_code => { -10 => 1 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{status} = [
|
||||||
|
{
|
||||||
|
label => 'status', type => 2, critical_default => '%{enabled} eq "yes" and %{state} eq "down"',
|
||||||
|
set => {
|
||||||
|
key_values => [ { name => 'enabled' }, { name => 'state' }, { name => 'name' } ],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{signal} = [
|
||||||
|
{ label => 'chain0-signal-receive-power', nlabel => 'radio.interface.chain0.signal.receive.power.dbm', set => {
|
||||||
|
key_values => [ { name => 'chain0_in_power' } ],
|
||||||
|
output_template => 'chain0 receive power: %s dBm',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, unit => 'dBm', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'chain1-signal-receive-power', nlabel => 'radio.interface.chain1.signal.receive.power.dbm', set => {
|
||||||
|
key_values => [ { name => 'chain1_in_power' } ],
|
||||||
|
output_template => 'chain1 receive power: %s dBm',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, unit => 'dBm', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{traffic} = [
|
||||||
|
{ label => 'traffic-in', nlabel => 'radio.interface.traffic.in.bitspersecond', set => {
|
||||||
|
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||||
|
output_template => 'in: %s %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-out', nlabel => 'radio.interface.traffic.out.bitspersecond', set => {
|
||||||
|
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||||
|
output_template => 'out: %s %s/s',
|
||||||
|
output_change_bytes => 2,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-name:s' => { name => 'filter_name' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $map_state = { 0 => 'down', 1 => 'up' };
|
||||||
|
my $map_enabled = { 1 => 'yes', 2 => 'no' };
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
enabled => { oid => '.1.3.6.1.4.1.41112.1.3.1.1.2', map => $map_enabled }, # radioEnable
|
||||||
|
state => { oid => '.1.3.6.1.4.1.41112.1.3.2.1.26', map => $map_state }, # radioLinkState
|
||||||
|
chain0_in_power => { oid => '.1.3.6.1.4.1.41112.1.3.2.1.11' }, # rxPower0
|
||||||
|
chain1_in_power => { oid => '.1.3.6.1.4.1.41112.1.3.2.1.14' }, # rxPower1
|
||||||
|
total_out => { oid => '.1.3.6.1.4.1.41112.1.3.3.1.6' }, # txOctetsOK
|
||||||
|
total_in => { oid => '.1.3.6.1.4.1.41112.1.3.3.1.19' } # rxTotalOctets
|
||||||
|
};
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{cache_name} = 'ubiquiti_airfiber_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||||
|
|
||||||
|
my $oid_name = '.1.3.6.1.4.1.41112.1.3.1.1.14'; # linkName
|
||||||
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
|
oid => $oid_name,
|
||||||
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
$self->{radios} = {};
|
||||||
|
foreach (keys %$snmp_result) {
|
||||||
|
/\.(\d+)$/;
|
||||||
|
my $instance = $1;
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$snmp_result->{$_} !~ /$self->{option_results}->{filter_name}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping radio interface '" . $snmp_result->{$_} . "'.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{radios}->{ $snmp_result->{$_} } = {
|
||||||
|
name => $snmp_result->{$_},
|
||||||
|
instance => $instance
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (scalar(keys %{$self->{radios}}) <= 0);
|
||||||
|
|
||||||
|
$options{snmp}->load(
|
||||||
|
oids => [ map($_->{oid}, values(%$mapping)) ],
|
||||||
|
instances => [ map($_->{instance}, values(%{$self->{radios}})) ],
|
||||||
|
instance_regexp => '^(.*)$'
|
||||||
|
);
|
||||||
|
$snmp_result = $options{snmp}->get_leef();
|
||||||
|
foreach (keys %{$self->{radios}}) {
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $self->{radios}->{$_}->{instance});
|
||||||
|
|
||||||
|
$self->{radios}->{$_}->{status} = { state => $result->{state}, enabled => $result->{enabled}, name => $_ };
|
||||||
|
$self->{radios}->{$_}->{traffic} = { traffic_in => $result->{total_in} * 8, traffic_out => $result->{total_out} * 8 };
|
||||||
|
$self->{radios}->{$_}->{signal} = { chain0_in_power => $result->{chain0_in_power}, chain1_in_power => $result->{chain1_in_power} };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check radio interfaces.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter interface by name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--unknown-status>
|
||||||
|
|
||||||
|
Set unknown threshold for status.
|
||||||
|
Can used special variables like: %{enabled}, %{state}, %{name}
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{enabled}, %{state}, %{name}
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: '%{enabled} eq "yes" and %{state} eq "down"').
|
||||||
|
Can used special variables like: %{enabled}, %{state}, %{name}
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'traffic-in', 'traffic-out', 'chain0-signal-receive-power', 'chain1-signal-receive-power'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,52 @@
|
||||||
|
#
|
||||||
|
# Copyright 2021 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package network::ubiquiti::airfiber::snmp::plugin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use base qw(centreon::plugins::script_snmp);
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '0.1';
|
||||||
|
$self->{modes} = {
|
||||||
|
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||||
|
'load' => 'centreon::common::frogfoot::snmp::mode::load',
|
||||||
|
'list-radios' => 'network::ubiquiti::airfiber::snmp::mode::listradios',
|
||||||
|
'memory' => 'centreon::common::frogfoot::snmp::mode::memory',
|
||||||
|
'radios' => 'network::ubiquiti::airfiber::snmp::mode::radios'
|
||||||
|
};
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
Check Ubiquiti AirFiber in SNMP.
|
||||||
|
|
||||||
|
=cut
|
Loading…
Reference in New Issue