(plugin) network::cambium::epmp::snmp - add cambium SNMP plugin (#3649)

* add cambium snmp plugin

* move files to sub dir epmp

* path correction and adding interfaces and uptime

* Update network/cambium/epmp/snmp/plugin.pm
This commit is contained in:
lchrdn 2022-05-09 16:33:41 +02:00 committed by GitHub
parent ed3b452d6e
commit 29c58019c1
6 changed files with 613 additions and 0 deletions

View File

@ -0,0 +1,89 @@
#
# Copyright 2022 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::cambium::epmp::snmp::mode::antenna;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'antenna-gain', nlabel => 'antenna.gain.dBi', set => {
key_values => [ { name => 'antenna_gain' } ],
output_template => 'Antenna gain: %d dBi',
perfdatas => [
{ template => '%d', max => 40 }
]
}
}
];
}
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_effective_antenna_gain = '.1.3.6.1.4.1.17713.21.1.1.9.0'; # cambiumEffectiveAntennaGain
my $snmp_result = $options{snmp}->get_leef(
oids => [$oid_effective_antenna_gain],
nothing_quit => 1
);
$self->{global} = {
antenna_gain => $snmp_result->{$oid_effective_antenna_gain}
};
}
1;
__END__
=head1 MODE
Check antenna gain.
=over 8
=item B<--warning-antenna-gain>
Warning threshold for antenna gain in dBi.
=item B<--critical-antenna-gain>
Critical threshold for antenna gain in dBi.
=back
=cut

View File

@ -0,0 +1,87 @@
#
# Copyright 2022 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::cambium::epmp::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }
];
$self->{maps_counters}->{global} = [
{ label => 'cpu', nlabel => 'system.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu' } ],
output_template => 'CPU usage: %.2f%% ',
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_sysCPUUsage = '.1.3.6.1.4.1.17713.21.2.1.64.0';
my $snmp_result = $options{snmp}->get_leef(
oids => [ $oid_sysCPUUsage ] ,
nothing_quit => 1
);
$self->{global} = { 'cpu' => ($snmp_result->{$oid_sysCPUUsage} / 10) };
}
1;
__END__
=head1 MODE
Check CPU usage.
=over 8
=item B<--warning-cpu>
Warning threshold for CPU.
=item B<--critical-cpu>
Warning threshold for CPU.
=back
=cut

View File

@ -0,0 +1,182 @@
#
# Copyright 2022 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::cambium::epmp::snmp::mode::interfaces;
use base qw(snmp_standard::mode::interfaces);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check interfaces.
=over 8
=item B<--add-global>
Check global port statistics (By default if no --add-* option is set).
=item B<--add-status>
Check interface status.
=item B<--add-duplex-status>
Check duplex status (with --warning-status and --critical-status).
=item B<--add-traffic>
Check interface traffic.
=item B<--add-errors>
Check interface errors.
=item B<--add-cast>
Check interface cast.
=item B<--add-speed>
Check interface speed.
=item B<--add-volume>
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
=item B<--check-metrics>
If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"').
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
=item B<--critical-status>
Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
'speed' (b/s).
=item B<--units-traffic>
Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter').
=item B<--units-errors>
Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
=item B<--units-cast>
Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
=item B<--nagvis-perfdata>
Display traffic perfdata to be compatible with nagvis widget.
=item B<--interface>
Set the interface (number expected) ex: 1,2,... (empty means 'check all interface').
=item B<--name>
Allows to use interface name with option --interface instead of interface oid index (Can be a regexp)
=item B<--speed>
Set interface speed for incoming/outgoing traffic (in Mb).
=item B<--speed-in>
Set interface speed for incoming traffic (in Mb).
=item B<--speed-out>
Set interface speed for outgoing traffic (in Mb).
=item B<--map-speed-dsl>
Get interface speed configuration for interface type 'adsl' and 'vdsl2'.
Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name
E.g: --map-speed-dsl=Et0.835,Et0-vdsl2
=item B<--force-counters64>
Force to use 64 bits counters only. Can be used to improve performance.
=item B<--force-counters32>
Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy.
=item B<--reload-cache-time>
Time in minutes before reloading cache file (default: 180).
=item B<--oid-filter>
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
=item B<--oid-display>
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
=item B<--oid-extra-display>
Add an OID to display.
=item B<--display-transform-src>
Regexp src to transform display value.
=item B<--display-transform-dst>
Regexp dst to transform display value.
=item B<--show-cache>
Display cache interface datas.
=back
=cut

View File

@ -0,0 +1,125 @@
#
# Copyright 2022 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::cambium::epmp::snmp::mode::license;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'status',
type => 2,
unknown_default => '%{status} =~ /unknown/i',
warning_default => '%{status} =~ /validation fail|not provided/i',
critical_default => '%{status} =~ /not valid/i',
set => {
key_values => [ { name => 'status' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];
}
sub custom_status_output {
my ($self, %options) = @_;
return 'License status: ' . $self->{result_values}->{status};
}
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;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
}
my $map_status = {
0 => 'Unknown',
1 => 'License Valid',
2 => 'Validation procedure was not provided',
3 => 'Validation Fail',
4 => 'License not valid for current device'
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_cambLicenseStatus = '.1.3.6.1.4.1.17713.21.1.8.5.0';
my $snmp_result = $options{snmp}->get_leef(
oids => [ $oid_cambLicenseStatus ],
nothing_quit => 1
);
$self->{global} = {
status => $map_status->{ $snmp_result->{$oid_cambLicenseStatus} }
};
}
1;
__END__
=head1 MODE
Check Cambium license status.
=over 8
=item B<--unknown-status>
Set unknown threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{status}
=item B<--warning-status>
Set warning threshold for status (Default: '%{status} =~ /validation fail|not provided/i').
Can used special variables like: %{status}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /not valid/i').
Can used special variables like: %{status}
=back
=cut

View File

@ -0,0 +1,77 @@
#
# Copyright 2022 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::cambium::epmp::snmp::mode::uptime;
use base qw(snmp_standard::mode::uptime);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check system uptime.
=over 8
=item B<--warning-uptime>
Threshold warning.
=item B<--critical-uptime>
Threshold critical.
=item B<--add-sysdesc>
Display system description.
=item B<--force-oid>
Can choose your oid (numeric format only).
=item B<--check-overload>
Uptime counter limit is 4294967296 and overflow.
With that option, we manage the counter going back. But there is a few chance we can miss a reboot.
=item B<--reboot-window>
To be used with check-overload option. Time in milliseconds (Default: 5000)
You increase the chance of not missing a reboot if you decrease that value.
=item B<--unit>
Select the unit for performance data and thresholds. May be 's' for seconds, 'm' for minutes,
'h' for hours, 'd' for days, 'w' for weeks. Default is seconds
=back

View File

@ -0,0 +1,53 @@
#
# Copyright 2022 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::cambium::epmp::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} = {
'antenna' => 'network::cambium::epmp::snmp::mode::antenna',
'cpu' => 'network::cambium::epmp::snmp::mode::cpu',
'interfaces' => 'network::cambium::epmp::snmp::mode::interfaces',
'license' => 'network::cambium::epmp::snmp::mode::license',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'uptime' => 'network::cambium::epmp::snmp::mode::uptime',
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Cambium ePMP equipments through SNMP.
=cut