Merge pull request #931 from cgagnaire/872-add-mode-f5-trunk

add modes trunks and list-trunks
This commit is contained in:
Simon Bomm 2018-04-09 10:15:54 +02:00 committed by GitHub
commit ee37de83ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 643 additions and 0 deletions

View File

@ -0,0 +1,150 @@
#
# Copyright 2018 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::f5::bigip::snmp::mode::listtrunks;
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;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
});
$self->{trunks_selected} = [];
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my %map_trunk_status = (
0 => 'up',
1 => 'down',
2 => 'disable',
3 => 'uninitialized',
4 => 'loopback',
5 => 'unpopulated',
);
my $sysTrunkTable = '.1.3.6.1.4.1.3375.2.1.2.12.1.2';
my $sysTrunkName = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.1';
my $sysTrunkStatus = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.2';
my $sysTrunkOperBw = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.5';
sub manage_selection {
my ($self, %options) = @_;
$self->{result} = $self->{snmp}->get_table(oid => $sysTrunkTable, nothing_quit => 1);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
next if ($oid !~ /^$sysTrunkName\.(.*)$/);
my $instance = $1;
# Get all without a name
if (!defined($self->{option_results}->{name})) {
push @{$self->{trunks_selected}}, $instance;
next;
}
if (!defined($self->{option_results}->{use_regexp}) && $self->{result}->{$sysTrunkName . '.' . $instance} eq $self->{option_results}->{name}) {
push @{$self->{trunks_selected}}, $instance;
next;
}
if (defined($self->{option_results}->{use_regexp}) && $self->{result}->{$sysTrunkName . '.' . $instance} =~ /$self->{option_results}->{name}/) {
push @{$self->{trunks_selected}}, $instance;
next;
}
$self->{output}->output_add(long_msg => "Skipping pool '" . $self->{result}->{$sysTrunkName . '.' . $instance} . "': no matching filter name", debug => 1);
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection();
foreach my $instance (sort @{$self->{trunks_selected}}) {
$self->{output}->output_add(long_msg => sprintf("'%s' [status: %s] [speed: %s]",
$self->{result}->{$sysTrunkName . '.' . $instance},
$map_trunk_status{$self->{result}->{$sysTrunkStatus . '.' . $instance}},
$self->{result}->{$sysTrunkOperBw . '.' . $instance}));
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List Trunks:');
$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', 'status', 'speed']);
}
sub disco_show {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection(disco => 1);
foreach my $instance (sort @{$self->{trunks_selected}}) {
my $name = $self->{result}->{$sysTrunkName . '.' . $instance};
my $status = $map_trunk_status{$self->{result}->{$sysTrunkStatus . '.' . $instance}};
my $speed = $self->{result}->{$sysTrunkOperBw . '.' . $instance};
$self->{output}->add_disco_entry(name => $name, status => $status, speed => $speed);
}
}
1;
__END__
=head1 MODE
List Trunks.
=over 8
=item B<--name>
Set the trunk name.
=item B<--regexp>
Allows to use regexp to filter trunk name (with option --name).
=back
=cut

View File

@ -0,0 +1,491 @@
#
# Copyright 2018 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::f5::bigip::snmp::mode::trunks;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
my $thresholds = {
trunk => [
['up', 'OK'],
['down', 'CRITICAL'],
['disable', 'CRITICAL'],
['uninitialized', 'CRITICAL'],
['loopback', 'OK'],
['unpopulated', 'OK'],
],
};
sub custom_threshold_output {
my ($self, %options) = @_;
return $instance_mode->get_severity(section => 'trunk', value => $self->{result_values}->{sysTrunkStatus});
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{sysTrunkStatus} = $options{new_datas}->{$self->{instance} . '_sysTrunkStatus'};
return 0;
}
sub custom_traffic_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
my ($warning, $critical);
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-traffic-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-traffic-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-traffic-' . $self->{label});
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-traffic-' . $self->{label});
}
$self->{output}->perfdata_add(label => 'traffic_' . $self->{result_values}->{label} . $extra_label, unit => 'b/s',
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
warning => $warning,
critical => $critical,
min => 0, max => $self->{result_values}->{speed});
}
sub custom_traffic_threshold {
my ($self, %options) = @_;
my $exit = 'ok';
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-traffic-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-traffic-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
}
return $exit;
}
sub custom_traffic_output {
my ($self, %options) = @_;
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
my $msg = sprintf("Traffic %s : %s/s (%s)",
ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit,
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-');
return $msg;
}
sub custom_traffic_calc {
my ($self, %options) = @_;
if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}})) {
$self->{error_msg} = "buffer creation";
return -2;
}
my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}});
if ($diff_traffic == 0 && !defined($instance_mode->{option_results}->{no_skipped_counters})) {
$self->{error_msg} = "skipped";
return -2;
}
$self->{result_values}->{speed} = defined($instance_mode->{option_results}->{speed}) ? $instance_mode->{option_results}->{speed} : $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{speed}};
$self->{result_values}->{speed} = $self->{result_values}->{speed} * 1000 * 1000; # bits
$self->{result_values}->{traffic_per_seconds} = $diff_traffic * 8 / $options{delta_time};
$self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_seconds} * 100 / $self->{result_values}->{speed};
$self->{result_values}->{label} = $options{extra_options}->{label};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub custom_errors_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
my $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '-error');
my $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '-error');
$self->{output}->perfdata_add(label => 'packets_error_' . $self->{result_values}->{label} . $extra_label, unit => '%',
value => sprintf("%.2f", $self->{result_values}->{errors_prct}),
warning => $warning,
critical => $critical,
min => 0, max => 100);
}
sub custom_errors_threshold {
my ($self, %options) = @_;
my $exit = 'ok';
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{errors_prct}, threshold => [ { label => 'critical-' . $self->{label} . '-error', exit_litteral => 'critical' }, { label => 'warning-' . $self->{label} . '-error', exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_errors_output {
my ($self, %options) = @_;
my $msg = sprintf("Packets %s Error : %s",
ucfirst($self->{result_values}->{label}), defined($self->{result_values}->{errors_prct}) ? sprintf("%.2f%%", $self->{result_values}->{errors_prct}) : '-');
return $msg;
}
sub custom_errors_calc {
my ($self, %options) = @_;
if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{errors}})) {
$self->{error_msg} = "buffer creation";
return -2;
}
my $diff_errors = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{errors}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{errors}});
my $diff_packets = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{packets}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{packets}});
if ($diff_errors == 0 || $diff_packets == 0 && !defined($instance_mode->{option_results}->{no_skipped_counters})) {
$self->{error_msg} = "skipped";
return -2;
}
$self->{result_values}->{errors_prct} = $diff_errors * 100 / $diff_packets;
$self->{result_values}->{label} = $options{extra_options}->{label};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub custom_drops_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
my $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '-drop');
my $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '-drop');
$self->{output}->perfdata_add(label => 'packets_drop_' . $self->{result_values}->{label} . $extra_label, unit => '%',
value => sprintf("%.2f", $self->{result_values}->{drops_prct}),
warning => $warning,
critical => $critical,
min => 0, max => 100);
}
sub custom_drops_threshold {
my ($self, %options) = @_;
my $exit = 'ok';
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{drops_prct}, threshold => [ { label => 'critical-' . $self->{label} . '-drop', exit_litteral => 'critical' }, { label => 'warning-' . $self->{label} . '-drop', exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_drops_output {
my ($self, %options) = @_;
my $msg = sprintf("Packets %s Error : %s",
ucfirst($self->{result_values}->{label}), defined($self->{result_values}->{drops_prct}) ? sprintf("%.2f%%", $self->{result_values}->{drops_prct}) : '-');
return $msg;
}
sub custom_drops_calc {
my ($self, %options) = @_;
if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{drops}})) {
$self->{error_msg} = "buffer creation";
return -2;
}
my $diff_drops = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{drops}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{drops}});
my $diff_packets = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{packets}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{packets}});
if ($diff_drops == 0 || $diff_packets == 0 && !defined($instance_mode->{option_results}->{no_skipped_counters})) {
$self->{error_msg} = "skipped";
return -2;
}
$self->{result_values}->{drops_prct} = $diff_drops * 100 / $diff_packets;
$self->{result_values}->{label} = $options{extra_options}->{label};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'trunks', type => 1, cb_prefix_output => 'prefix_trunks_output', message_multiple => 'All trunks are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{trunks} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'sysTrunkStatus' } ],
closure_custom_calc => $self->can('custom_status_calc'),
output_template => "status is '%s'", output_error_template => 'Status : %s',
output_use => 'sysTrunkStatus',
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
}
},
{ label => 'traffic-in', set => {
key_values => [ { name => 'sysTrunkStatBytesIn', diff => 1 }, { name => 'sysTrunkOperBw', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_traffic_calc'), per_second => 1,
closure_custom_calc_extra_options => { label_ref => 'sysTrunkStatBytesIn', speed => 'sysTrunkOperBw', label => 'in' },
closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s',
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
}
},
{ label => 'traffic-out', set => {
key_values => [ { name => 'sysTrunkStatBytesOut', diff => 1 }, { name => 'sysTrunkOperBw', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_traffic_calc'), per_second => 1,
closure_custom_calc_extra_options => { label_ref => 'sysTrunkStatBytesOut', speed => 'sysTrunkOperBw', label => 'out' },
closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s',
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
}
},
{ label => 'packets-error-in', set => {
key_values => [ { name => 'sysTrunkStatErrorsIn', diff => 1 }, { name => 'sysTrunkStatPktsIn', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_errors_calc'),
closure_custom_calc_extra_options => { errors => 'sysTrunkStatErrorsIn', packets => 'sysTrunkStatPktsIn', label => 'in' },
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Error : %s',
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
}
},
{ label => 'packets-error-out', set => {
key_values => [ { name => 'sysTrunkStatErrorsOut', diff => 1 }, { name => 'sysTrunkStatPktsOut', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_errors_calc'),
closure_custom_calc_extra_options => { errors => 'sysTrunkStatErrorsOut', packets => 'sysTrunkStatPktsOut', label => 'out' },
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Error : %s',
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
}
},
{ label => 'packets-drop-in', set => {
key_values => [ { name => 'sysTrunkStatDropsIn', diff => 1 }, { name => 'sysTrunkStatPktsIn', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_errors_calc'),
closure_custom_calc_extra_options => { errors => 'sysTrunkStatDropsIn', packets => 'sysTrunkStatPktsIn', label => 'in' },
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Drop : %s',
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
}
},
{ label => 'packets-drop-out', set => {
key_values => [ { name => 'sysTrunkStatDropsOut', diff => 1 }, { name => 'sysTrunkStatPktsOut', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_errors_calc'),
closure_custom_calc_extra_options => { errors => 'sysTrunkStatDropsOut', packets => 'sysTrunkStatPktsOut', label => 'out' },
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Drop : %s',
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
}
},
];
}
sub prefix_trunks_output {
my ($self, %options) = @_;
return "Trunk '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"threshold-overload:s@" => { name => 'threshold_overload' },
"units-traffic:s" => { name => 'units_traffic', default => '%' },
"speed:s" => { name => 'speed' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ($1, $2, $3);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) {
$status = $_->{status};
return $status;
}
}
}
foreach (@{$thresholds->{$options{section}}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
my %map_trunk_status = (
0 => 'up',
1 => 'down',
2 => 'disable',
3 => 'uninitialized',
4 => 'loopback',
5 => 'unpopulated',
);
my $mapping_sysTrunk = {
sysTrunkName => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.1' },
sysTrunkStatus => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.2', map => \%map_trunk_status },
sysTrunkOperBw => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.5' },
};
my $oid_sysTrunkTable = '.1.3.6.1.4.1.3375.2.1.2.12.1.2';
my $mapping_sysTrunkStat = {
sysTrunkStatPktsIn => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.2' },
sysTrunkStatBytesIn => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.3' }, # Bytes
sysTrunkStatPktsOut => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.4' },
sysTrunkStatBytesOut => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.5' }, # Bytes
sysTrunkStatMcastIn => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.6' },
sysTrunkStatMcastOut => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.7' },
sysTrunkStatErrorsIn => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.8' },
sysTrunkStatErrorsOut => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.9' },
sysTrunkStatDropsIn => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.10' },
sysTrunkStatDropsOut => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.2.3.1.11' },
};
my $oid_sysTrunkStatTable = '.1.3.6.1.4.1.3375.2.1.2.12.2.3';
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
my $results = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_sysTrunkTable },
{ oid => $oid_sysTrunkStatTable },
], nothing_quit => 1);
$self->{trunks} = {};
foreach my $oid (keys %{$results->{$oid_sysTrunkTable}}) {
next if ($oid !~ /^$mapping_sysTrunk->{sysTrunkName}->{oid}\.(.*)$/);
my $instance = $1;
my $result_sysTrunk = $options{snmp}->map_instance(mapping => $mapping_sysTrunk, results => $results->{$oid_sysTrunkTable}, instance => $instance);
my $result_sysTrunkStat = $options{snmp}->map_instance(mapping => $mapping_sysTrunkStat, results => $results->{$oid_sysTrunkStatTable}, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result_sysTrunk->{sysTrunkName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result_sysTrunk->{sysTrunkName} . "': no matching filter name.", debug => 1);
next;
}
$self->{trunks}->{$result_sysTrunk->{sysTrunkName}} = {
display => $result_sysTrunk->{sysTrunkName},
%$result_sysTrunk, %$result_sysTrunkStat,
};
}
if (scalar(keys %{$self->{trunks}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No trunks found.");
$self->{output}->option_exit();
}
$self->{cache_name} = "f5_bipgip_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check Trunks usage.
=over 8
=item B<--filter-name>
Filter by trunks name (regexp can be used).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='trunk,CRITICAL,^(?!(up)$)'
=item B<--units-traffic>
Units of thresholds for the traffic (Default: '%') ('%', 'b/s').
=item B<--warning-*>
Threshold warning.
Can be: 'traffic-in', 'traffic-out', 'packets-error-in',
'packets-error-out', 'packets-drop-in', 'packets-drop-out'
=item B<--critical-*>
Threshold critical.
Can be: 'traffic-in', 'traffic-out', 'packets-error-in',
'packets-error-out', 'packets-drop-in', 'packets-drop-out'
=item B<--speed>
Set trunk speed in Mbps (Default: sysTrunkOperBw).
=back
=cut

View File

@ -36,10 +36,12 @@ sub new {
'hardware' => 'network::f5::bigip::snmp::mode::hardware',
'list-nodes' => 'network::f5::bigip::snmp::mode::listnodes',
'list-pools' => 'network::f5::bigip::snmp::mode::listpools',
'list-trunks' => 'network::f5::bigip::snmp::mode::listtrunks',
'list-virtualservers' => 'network::f5::bigip::snmp::mode::listvirtualservers',
'node-status' => 'network::f5::bigip::snmp::mode::nodestatus',
'pool-status' => 'network::f5::bigip::snmp::mode::poolstatus',
'tmm-usage' => 'network::f5::bigip::snmp::mode::tmmusage',
'trunks' => 'network::f5::bigip::snmp::mode::trunks',
'virtualserver-status' => 'network::f5::bigip::snmp::mode::virtualserverstatus',
);