+ Remove old modes (Ref #77)

This commit is contained in:
garnier-quentin 2015-07-23 11:56:14 +02:00
parent 85aa122445
commit 22eec149a6
3 changed files with 0 additions and 1535 deletions

View File

@ -1,522 +0,0 @@
#
# Copyright 2015 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 snmp_standard::mode::anycast;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::values;
my $maps_counters = {
'status' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'opstatus' }, { name => 'admstatus' },
],
closure_custom_calc => \&custom_status_calc,
closure_custom_output => \&custom_status_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&custom_threshold_output,
}
},
'in-ucast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'iucast', total_ref1 => 'ibcast', total_ref2 => 'imcast' },
output_template => 'In Ucast : %.2f %%', output_error_template => 'In Ucast : %s',
output_use => 'iucast_prct', threshold_use => 'iucast_prct',
perfdatas => [
{ value => 'iucast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
'in-bcast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'ibcast', total_ref1 => 'iucast', total_ref2 => 'imcast' },
output_template => 'In Bcast : %.2f %%', output_error_template => 'In Bcast : %s',
output_use => 'ibcast_prct', threshold_use => 'ibcast_prct',
perfdatas => [
{ value => 'ibcast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
'in-mcast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'imcast', total_ref1 => 'iucast', total_ref2 => 'ibcast' },
output_template => 'In Mcast : %.2f %%', output_error_template => 'In Mcast : %s',
output_use => 'imcast_prct', threshold_use => 'imcast_prct',
perfdatas => [
{ value => 'imcast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
'out-ucast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'oucast', total_ref1 => 'omcast', total_ref2 => 'obcast' },
output_template => 'Out Ucast : %.2f %%', output_error_template => 'Out Ucast : %s',
output_use => 'oucast_prct', threshold_use => 'oucast_prct',
perfdatas => [
{ value => 'oucast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
'out-bcast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'obcast', total_ref1 => 'omcast', total_ref2 => 'oucast' },
output_template => 'Out Bcast : %.2f %%', output_error_template => 'Out Bcast : %s',
output_use => 'obcast_prct', threshold_use => 'obcast_prct',
perfdatas => [
{ value => 'obcast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
'out-mcast' => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode' }, { name => 'opstatus' }, { name => 'admstatus' }
],
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'omcast', total_ref1 => 'oucast', total_ref2 => 'obcast' },
output_template => 'Out Mcast : %.2f %%', output_error_template => 'Out Mcast : %s',
output_use => 'omcast_prct', threshold_use => 'omcast_prct',
perfdatas => [
{ value => 'omcast_prct', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
],
}
},
};
my $skip_option;
my @operstatus = ("up", "down", "testing", "unknown", "dormant", "notPresent", "lowerLayerDown");
sub custom_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
if ($operstatus[$self->{result_values}->{opstatus} - 1] ne "up") {
if (defined($skip_option)) {
return $status;
}
if (!defined($self->{result_values}->{admstatus}) || $operstatus[$self->{result_values}->{admstatus} - 1] eq 'up') {
$status = 'critical';
}
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'Status : ';
if ($operstatus[$self->{result_values}->{opstatus} - 1] ne "up") {
if (defined($skip_option)) {
$msg .= 'skipped';
return $msg;
}
if (!defined($self->{result_values}->{admstatus}) || $operstatus[$self->{result_values}->{admstatus} - 1] eq 'up') {
$msg .= 'not ready (' . $operstatus[$self->{result_values}->{admstatus} - 1] . ')';
} else {
$msg .= 'not ready (normal state)';
}
} else {
$msg .= 'up';
}
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'};
$self->{result_values}->{admstatus} = $options{new_datas}->{$self->{instance} . '_admstatus'};
return 0;
}
sub custom_cast_calc {
my ($self, %options) = @_;
if ($operstatus[$options{new_datas}->{$self->{instance} . '_opstatus'} - 1] ne "up") {
$self->{error_msg} = "skipped";
return -2;
}
my $diff_cast = ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}});
my $total = $diff_cast
+ ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{total_ref1}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{total_ref1}})
+ ($options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{total_ref2}} - $options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{total_ref2}});
if ($options{new_datas}->{$self->{instance} . '_mode'} ne $options{old_datas}->{$self->{instance} . '_mode'}) {
$self->{error_msg} = "buffer creation";
return -2;
}
if ($total == 0) {
$self->{error_msg} = "skipped";
return -2;
}
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{$options{extra_options}->{label_ref} . '_prct'} = $diff_cast * 100 / $total;
return 0;
}
my %oids_iftable = (
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1'
);
my $oid_ifAdminStatus = '.1.3.6.1.2.1.2.2.1.7';
my $oid_ifOperStatus = '.1.3.6.1.2.1.2.2.1.8';
my $oid_ifXEntry = '.1.3.6.1.2.1.31.1.1.1';
# 32bits
my $oid_ifInUcastPkts = '.1.3.6.1.2.1.2.2.1.11';
my $oid_ifInBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.3';
my $oid_ifInMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.2';
my $oid_ifOutUcastPkts = '.1.3.6.1.2.1.2.2.1.17';
my $oid_ifOutMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.4';
my $oid_ifOutBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.5';
# 64 bits
my $oid_ifHCInUcastPkts = '.1.3.6.1.2.1.31.1.1.1.7';
my $oid_ifHCInMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.8';
my $oid_ifHCInBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.9';
my $oid_ifHCOutUcastPkts = '.1.3.6.1.2.1.31.1.1.1.11';
my $oid_ifHCOutMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.12';
my $oid_ifHCOutBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.13';
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" => { name => 'use_name' },
"interface:s" => { name => 'interface' },
"skip" => { name => 'skip' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"oid-filter:s" => { name => 'oid_filter', default => 'ifname'},
"oid-display:s" => { name => 'oid_display', default => 'ifname'},
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
});
$self->{interface_selected} = {};
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
foreach (keys %{$maps_counters}) {
$options{options}->add_options(arguments => {
'warning-' . $_ . ':s' => { name => 'warning-' . $_ },
'critical-' . $_ . ':s' => { name => 'critical-' . $_ },
});
my $class = $maps_counters->{$_}->{class};
$maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value},
output => $self->{output}, perfdata => $self->{perfdata},
label => $_);
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
}
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
$self->{option_results}->{oid_filter} = lc($self->{option_results}->{oid_filter});
if ($self->{option_results}->{oid_filter} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-filter option.");
$self->{output}->option_exit();
}
$self->{option_results}->{oid_display} = lc($self->{option_results}->{oid_display});
if ($self->{option_results}->{oid_display} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-display option.");
$self->{output}->option_exit();
}
foreach (keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
}
$skip_option = $self->{option_results}->{skip};
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
my $multiple = 1;
if (scalar(keys %{$self->{interface_selected}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All interfaces are ok.');
}
$self->{new_datas} = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
$self->{new_datas}->{last_timestamp} = time();
foreach my $id (sort keys %{$self->{interface_selected}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->set(instance => $id);
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{interface_selected}->{$id},
new_datas => $self->{new_datas});
if ($value_check != 0) {
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
$long_msg_append = ', ';
next;
}
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
push @exits, $exit2;
my $output = $maps_counters->{$_}->{obj}->output();
$long_msg .= $long_msg_append . $output;
$long_msg_append = ', ';
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= $short_msg_append . $output;
$short_msg_append = ', ';
}
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
}
$self->{output}->output_add(long_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "' $long_msg");
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "' $short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "' $long_msg");
}
}
$self->{statefile_value}->write(data => $self->{new_datas});
$self->{output}->display();
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{value};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
}
return $value;
}
sub add_result {
my ($self, %options) = @_;
$self->{interface_selected}->{$options{instance}} = {};
$self->{interface_selected}->{$options{instance}}->{display} = $self->get_display_value(value => $self->{results}->{$oids_iftable{$self->{option_results}->{oid_display}}}->{$oids_iftable{$self->{option_results}->{oid_display}} . '.' . $options{instance}});
$self->{interface_selected}->{$options{instance}}->{opstatus} = $self->{results}->{$oid_ifOperStatus}->{$oid_ifOperStatus . '.' . $options{instance}};
$self->{interface_selected}->{$options{instance}}->{admstatus} = $self->{results}->{$oid_ifAdminStatus}->{$oid_ifAdminStatus . '.' . $options{instance}};
$self->{interface_selected}->{$options{instance}}->{mode} = 32;
$self->{interface_selected}->{$options{instance}}->{iucast} = $self->{results}->{$oid_ifInUcastPkts}->{$oid_ifInUcastPkts . '.' . $options{instance}};
$self->{interface_selected}->{$options{instance}}->{ibcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifInBroadcastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifInBroadcastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{imcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifInMulticastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifInMulticastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$oid_ifOutUcastPkts}->{$oid_ifOutUcastPkts . '.' . $options{instance}};
$self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifOutMulticastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifOutMulticastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifOutBroadcastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifOutBroadcastPkts . '.' . $options{instance}} : 0;
if (!$self->{snmp}->is_snmpv1()) {
my $iucast = $self->{results}->{$oid_ifXEntry}->{"${oid_ifHCInUcastPkts}.$options{instance}"};
if (defined($iucast) && $iucast =~ /[1-9]/) {
$self->{interface_selected}->{$options{instance}}->{iucast} = $iucast;
$self->{interface_selected}->{$options{instance}}->{imcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifHCInMulticastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifHCInMulticastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{ibcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifHCInBroadcastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifHCInBroadcastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$oid_ifXEntry}->{$oid_ifHCOutUcastPkts . '.' . $options{instance}};
$self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifHCOutMulticastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifHCOutMulticastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$oid_ifXEntry}->{$oid_ifHCOutBroadcastPkts . '.' . $options{instance}}) ? $self->{results}->{$oid_ifXEntry}->{$oid_ifHCOutBroadcastPkts . '.' . $options{instance}} : 0;
$self->{interface_selected}->{$options{instance}}->{mode} = 64;
}
}
}
sub manage_selection {
my ($self, %options) = @_;
my @extra_names = ();
my $start_xtable = $oid_ifInMulticastPkts;
my $end_xtable = $oid_ifOutBroadcastPkts;
if (!$self->{snmp}->is_snmpv1()) {
$end_xtable = $oid_ifHCOutBroadcastPkts;
}
if ($self->{option_results}->{oid_filter} eq 'ifname' || $self->{option_results}->{oid_display} eq 'ifname') {
push @extra_names, { oid => $oids_iftable{ifname} };
}
if ($self->{option_results}->{oid_filter} eq 'ifalias' || $self->{option_results}->{oid_display} eq 'ifalias') {
push @extra_names, { oid => $oids_iftable{ifalias} };
}
if ($self->{option_results}->{oid_filter} eq 'ifdesc' || $self->{option_results}->{oid_display} eq 'ifdesc') {
push @extra_names, { oid => $oids_iftable{ifdesc} };
}
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
{ oid => $oid_ifXEntry, start => $start_xtable, end => , $end_xtable},
{ oid => $oid_ifAdminStatus },
{ oid => $oid_ifOperStatus },
{ oid => $oid_ifInUcastPkts },
{ oid => $oid_ifOutUcastPkts },
@extra_names
],
, nothing_quit => 1);
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{interface})) {
if (!defined($self->{results}->{$oids_iftable{$self->{option_results}->{oid_display}}}->{$oids_iftable{$self->{option_results}->{oid_display}} . '.' . $self->{option_results}->{interface}})) {
$self->{output}->add_option_msg(short_msg => "No interface found for id '" . $self->{option_results}->{interface} . "'.");
$self->{output}->option_exit();
}
$self->add_result(instance => $self->{option_results}->{interface});
} else {
foreach my $oid (keys %{$self->{results}->{$oids_iftable{$self->{option_results}->{oid_filter}}}}) {
$oid =~ /\.(\d+)$/;
my $instance = $1;
my $filter_name = $self->{results}->{$oids_iftable{$self->{option_results}->{oid_filter}}}->{$oid};
if (!defined($self->{option_results}->{interface})) {
$self->add_result(instance => $instance);
next;
}
if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/i) {
$self->add_result(instance => $instance);
}
if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/) {
$self->add_result(instance => $instance);
}
if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{interface}) {
$self->add_result(instance => $instance);
}
}
if (scalar(keys %{$self->{interface_selected}}) <= 0) {
if (defined($self->{option_results}->{interface})) {
$self->{output}->add_option_msg(short_msg => "No interface found for name '" . $self->{option_results}->{interface} . "'.");
} else {
$self->{output}->add_option_msg(short_msg => "No interface found.");
}
$self->{output}->option_exit();
}
}
}
1;
__END__
=head1 MODE
Check interface unicast, broadcast and multicast usage.
=over 8
=item B<--warning-*>
Threshold warning (in percent).
Can be: 'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast'.
=item B<--critical-*>
Threshold critical (in percent).
Can be: 'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast'.
=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.
=item B<--regexp>
Allows to use regexp to filter interfaces (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
=item B<--skip>
Skip errors on interface status.
=item B<--oid-filter>
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--oid-display>
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
Regexp src to transform display value. (security risk!!!)
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
=back
=cut

View File

@ -1,506 +0,0 @@
#
# Copyright 2015 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 snmp_standard::mode::packeterrors;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
my @operstatus = ("up", "down", "testing", "unknown", "dormant", "notPresent", "lowerLayerDown");
my %oids_iftable = (
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1'
);
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 =>
{
"warning-in-discard:s" => { name => 'warning_in_discard' },
"critical-in-discard:s" => { name => 'critical_in_discard' },
"warning-out-discard:s" => { name => 'warning_out_discard' },
"critical-out-discard:s" => { name => 'critical_out_discard' },
"warning-in-error:s" => { name => 'warning_in_error' },
"critical-in-error:s" => { name => 'critical_in_error' },
"warning-out-error:s" => { name => 'warning_out_error' },
"critical-out-error:s" => { name => 'critical_out_error' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"name" => { name => 'use_name' },
"interface:s" => { name => 'interface' },
"skip" => { name => 'skip' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"oid-filter:s" => { name => 'oid_filter', default => 'ifname'},
"oid-display:s" => { name => 'oid_display', default => 'ifname'},
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
"show-cache" => { name => 'show_cache' },
});
$self->{interface_id_selected} = [];
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $label (('warning_in_discard', 'critical_in_discard', 'warning_out_discard', 'critical_out_discard',
'warning_in_error', 'critical_in_error', 'warning_out_error', 'critical_out_error')) {
my ($label_opt) = $label;
$label_opt =~ tr/_/-/;
if (($self->{perfdata}->threshold_validate(label => $label_opt, value => $self->{option_results}->{$label})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong " . $label_opt . " threshold '" . $self->{option_results}->{$label} . "'.");
$self->{output}->option_exit();
}
}
$self->{option_results}->{oid_filter} = lc($self->{option_results}->{oid_filter});
if ($self->{option_results}->{oid_filter} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-filter option.");
$self->{output}->option_exit();
}
$self->{option_results}->{oid_display} = lc($self->{option_results}->{oid_display});
if ($self->{option_results}->{oid_display} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-display option.");
$self->{output}->option_exit();
}
$self->{statefile_cache}->check_options(%options);
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
my $oid_adminstatus = '.1.3.6.1.2.1.2.2.1.7';
my $oid_operstatus = '.1.3.6.1.2.1.2.2.1.8';
# 32bits
my $oid_ifInUcastPkts = '.1.3.6.1.2.1.2.2.1.11';
my $oid_ifInBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.3';
my $oid_ifInMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.2';
my $oid_ifOutUcastPkts = '.1.3.6.1.2.1.2.2.1.17';
my $oid_ifOutMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.4';
my $oid_ifOutBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.5';
# 64 bits
my $oid_ifHCInUcastPkts = '.1.3.6.1.2.1.31.1.1.1.7';
my $oid_ifHCInMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.8';
my $oid_ifHCInBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.9';
my $oid_ifHCOutUcastPkts = '.1.3.6.1.2.1.31.1.1.1.11';
my $oid_ifHCOutMulticastPkts = '.1.3.6.1.2.1.31.1.1.1.12';
my $oid_ifHCOutBroadcastPkts = '.1.3.6.1.2.1.31.1.1.1.13';
# 'discard' 'error' only 32 bits
my $oid_ifInDiscards = '.1.3.6.1.2.1.2.2.1.13';
my $oid_ifInErrors = '.1.3.6.1.2.1.2.2.1.14';
my $oid_ifOutDiscards = '.1.3.6.1.2.1.2.2.1.19';
my $oid_ifOutErrors = '.1.3.6.1.2.1.2.2.1.20';
my $new_datas = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
foreach (@{$self->{interface_id_selected}}) {
$self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_,
$oid_ifInUcastPkts . "." . $_, $oid_ifInBroadcastPkts . "." . $_, $oid_ifInMulticastPkts . "." . $_,
$oid_ifOutUcastPkts . "." . $_, $oid_ifOutMulticastPkts . "." . $_, $oid_ifOutBroadcastPkts . "." . $_,
$oid_ifInDiscards . "." . $_, $oid_ifInErrors . "." . $_,
$oid_ifOutDiscards . "." . $_, $oid_ifOutErrors . "." . $_]);
if (!$self->{snmp}->is_snmpv1()) {
$self->{snmp}->load(oids => [$oid_ifHCInUcastPkts . "." . $_, $oid_ifHCInMulticastPkts . "." . $_, $oid_ifHCInMulticastPkts . "." . $_,
$oid_ifHCOutUcastPkts . "." . $_, $oid_ifHCOutMulticastPkts . "." . $_, $oid_ifHCOutBroadcastPkts . "." . $_]);
}
}
my $result = $self->{snmp}->get_leef(nothing_quit => 1);
$new_datas->{last_timestamp} = time();
my $buffer_creation = 0;
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
if (!defined($self->{option_results}->{interface}) || defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All interfaces are ok.');
}
foreach (sort @{$self->{interface_id_selected}}) {
my $display_value = $self->get_display_value(id => $_);
if ($operstatus[$result->{$oid_operstatus . "." . $_} - 1] ne "up") {
if (!defined($self->{option_results}->{skip}) && (!defined($result->{$oid_adminstatus . "." . $_}) || $operstatus[$result->{$oid_adminstatus . "." . $_} - 1] eq 'up') ) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Interface '" . $display_value . "' is not ready: " . $operstatus[$result->{$oid_operstatus . "." . $_} - 1]);
} else {
# Avoid empty message
if (defined($self->{option_results}->{interface}) && !defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Interface '" . $display_value . "' is not up (normal state)");
}
$self->{output}->output_add(long_msg => "Skip interface '" . $display_value . "'.");
}
next;
}
#################
# New values
#################
my $old_mode = $self->{statefile_value}->get(name => 'mode_' . $_);
$new_datas->{'mode_' . $_} = '32';
$new_datas->{'in_discard_' . $_} = $result->{$oid_ifInDiscards . "." . $_};
$new_datas->{'in_error_' . $_} = $result->{$oid_ifInErrors . "." . $_};
$new_datas->{'out_discard_' . $_} = $result->{$oid_ifOutDiscards . "." . $_};
$new_datas->{'out_error_' . $_} = $result->{$oid_ifOutErrors . "." . $_};
$new_datas->{'in_ucast_' . $_} = $result->{$oid_ifInUcastPkts . "." . $_};
$new_datas->{'in_bcast_' . $_} = defined($result->{$oid_ifInBroadcastPkts . "." . $_}) ? $result->{$oid_ifInBroadcastPkts . "." . $_} : 0;
$new_datas->{'in_mcast_' . $_} = defined($result->{$oid_ifInMulticastPkts . "." . $_}) ? $result->{$oid_ifInMulticastPkts . "." . $_} : 0;
$new_datas->{'out_ucast_' . $_} = $result->{$oid_ifOutUcastPkts . "." . $_};
$new_datas->{'out_bcast_' . $_} = defined($result->{$oid_ifOutMulticastPkts . "." . $_}) ? $result->{$oid_ifOutMulticastPkts . "." . $_} : 0;
$new_datas->{'out_mcast_' . $_} = defined($result->{$oid_ifOutBroadcastPkts . "." . $_}) ? $result->{$oid_ifOutBroadcastPkts . "." . $_} : 0;
if (defined($result->{$oid_ifHCInUcastPkts . "." . $_}) && $result->{$oid_ifHCInUcastPkts . "." . $_} ne '' && $result->{$oid_ifHCInUcastPkts . "." . $_} != 0) {
$new_datas->{'in_ucast_' . $_} = $result->{$oid_ifHCInUcastPkts . "." . $_};
$new_datas->{'in_mcast_' . $_} = defined($result->{$oid_ifHCInMulticastPkts . "." . $_}) ? $result->{$oid_ifHCInMulticastPkts . "." . $_} : 0;
$new_datas->{'in_bcast_' . $_} = defined($result->{$oid_ifHCInBroadcastPkts . "." . $_}) ? $result->{$oid_ifHCInBroadcastPkts . "." . $_} : 0;
$new_datas->{'out_ucast_' . $_} = $result->{$oid_ifHCOutUcastPkts . "." . $_};
$new_datas->{'out_mcast_' . $_} = defined($result->{$oid_ifHCOutMulticastPkts . "." . $_}) ? $result->{$oid_ifHCOutMulticastPkts . "." . $_} : 0;
$new_datas->{'out_bcast_' . $_} = defined($result->{$oid_ifHCOutBroadcastPkts . "." . $_}) ? $result->{$oid_ifHCOutBroadcastPkts . "." . $_} : 0;
$new_datas->{'mode_' . $_} = '64';
}
# We change mode. need to recreate a buffer
if (!defined($old_timestamp) || !defined($old_mode) || $new_datas->{'mode_' . $_} ne $old_mode) {
$buffer_creation = 1;
next;
}
#################
# Old values
#################
my @getting = ('in_ucast', 'in_bcast', 'in_mcast', 'out_ucast', 'out_bcast', 'out_mcast',
'in_discard', 'in_error', 'out_discard', 'out_error');
my $old_datas = {};
foreach my $key (@getting) {
$old_datas->{$key} = $self->{statefile_value}->get(name => $key . '_' . $_);
if (!defined($old_datas->{$key}) || $new_datas->{$key . '_' . $_} < $old_datas->{$key}) {
# We set 0. Has reboot.
$old_datas->{$key} = 0;
}
}
my $time_delta = $new_datas->{last_timestamp} - $old_timestamp;
if ($time_delta <= 0) {
# At least one second. two fast calls ;)
$time_delta = 1;
}
############
my $total_in_packets = ($new_datas->{'in_ucast_' . $_} - $old_datas->{in_ucast}) + ($new_datas->{'in_bcast_' . $_} - $old_datas->{in_bcast}) + ($new_datas->{'in_mcast_' . $_} - $old_datas->{in_mcast});
my $total_out_packets = ($new_datas->{'out_ucast_' . $_} - $old_datas->{out_ucast}) + ($new_datas->{'out_bcast_' . $_} - $old_datas->{out_bcast}) + ($new_datas->{'out_mcast_' . $_} - $old_datas->{out_mcast});
my $delta_in_discard = defined($new_datas->{'in_discard_' . $_}) ? ($new_datas->{'in_discard_' . $_} - $old_datas->{in_discard}) : 0;
my $delta_in_error = defined($new_datas->{'in_error_' . $_}) ? ($new_datas->{'in_error_' . $_} - $old_datas->{in_error}) : 0;
my $delta_out_discard = defined($new_datas->{'out_discard_' . $_}) ? ($new_datas->{'out_discard_' . $_} - $old_datas->{out_discard}) : 0;
my $delta_out_error = defined($new_datas->{'out_error_' . $_}) ? ($new_datas->{'out_error_' . $_} - $old_datas->{out_error}) : 0;
my $in_discard_absolute_per_sec = $delta_in_discard / $time_delta;
my $in_error_absolute_per_sec = $delta_in_error / $time_delta;
my $out_discard_absolute_per_sec = $delta_out_discard / $time_delta;
my $out_error_absolute_per_sec = $delta_out_error / $time_delta;
my $in_discard_prct = sprintf("%.2f", ($total_in_packets == 0) ? 0 : $delta_in_discard * 100 / $total_in_packets);
my $in_error_prct = sprintf("%.2f", ($total_in_packets == 0) ? 0 : $delta_in_error * 100 / $total_in_packets);
my $out_discard_prct = sprintf("%.2f", ($total_out_packets == 0) ? 0 : $delta_out_discard * 100 / $total_out_packets);
my $out_error_prct = sprintf("%.2f", ($total_out_packets == 0) ? 0 : $delta_out_error * 100 / $total_out_packets);
###########
# Manage Output
###########
my $exit1 = $self->{perfdata}->threshold_check(value => $in_discard_prct, threshold => [ { label => 'critical-in-discard', 'exit_litteral' => 'critical' }, { label => 'warning-in-discard', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $in_error_prct, threshold => [ { label => 'critical-in-error', 'exit_litteral' => 'critical' }, { label => 'warning-in-error', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $out_discard_prct, threshold => [ { label => 'critical-out-discard', 'exit_litteral' => 'critical' }, { label => 'warning-out-discard', exit_litteral => 'warning' } ]);
my $exit4 = $self->{perfdata}->threshold_check(value => $out_error_prct, threshold => [ { label => 'critical-out-error', 'exit_litteral' => 'critical' }, { label => 'warning-out-error', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3, $exit4 ]);
$self->{output}->output_add(long_msg => sprintf("Interface '%s' Packets In Discard : %s, In Error : %s, Out Discard: %s, Out Error: %s", $display_value,
defined($new_datas->{'in_discard_' . $_}) ? $in_discard_prct . ' % (' . $delta_in_discard . ')' : 'unknown',
defined($new_datas->{'in_error_' . $_}) ? $in_error_prct . ' % (' . $delta_in_error . ')' : 'unknown',
defined($new_datas->{'out_discard_' . $_}) ? $out_discard_prct . ' % (' . $delta_out_discard . ')' : 'unknown',
defined($new_datas->{'out_error_' . $_}) ? $out_error_prct . ' % (' . $delta_out_error . ')' : 'unknown'
));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{interface}) && !defined($self->{option_results}->{use_regexp}))) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Interface '%s' Packets In Discard : %s, In Error : %s, Out Discard: %s, Out Error: %s", $display_value,
defined($new_datas->{'in_discard_' . $_}) ? $in_discard_prct . ' % (' . $delta_in_discard . ')' : 'unknown',
defined($new_datas->{'in_error_' . $_}) ? $in_error_prct . ' % (' . $delta_in_error . ')' : 'unknown',
defined($new_datas->{'out_discard_' . $_}) ? $out_discard_prct . ' % (' . $delta_out_discard . ')' : 'unknown',
defined($new_datas->{'out_error_' . $_}) ? $out_error_prct . ' % (' . $delta_out_error . ')' : 'unknown'
));
}
my $extra_label = '';
$extra_label = '_' . $display_value if (!defined($self->{option_results}->{interface}) || defined($self->{option_results}->{use_regexp}));
if (defined($new_datas->{'in_discard_' . $_})) {
$self->{output}->perfdata_add(label => 'packets_discard_in' . $extra_label, unit => '%',
value => $in_discard_prct,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-in-discard'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-in-discard'),
min => 0, max => 100);
}
if (defined($new_datas->{'in_error_' . $_})) {
$self->{output}->perfdata_add(label => 'packets_error_in' . $extra_label, unit => '%',
value => $in_error_prct,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-in-error'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-in-error'),
min => 0, max => 100);
}
if (defined($new_datas->{'out_discard_' . $_})) {
$self->{output}->perfdata_add(label => 'packets_discard_out' . $extra_label, unit => '%',
value => $out_discard_prct,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-out-discard'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-out-discard'),
min => 0, max => 100);
}
if (defined($new_datas->{'out_error_' . $_})) {
$self->{output}->perfdata_add(label => 'packets_error_out' . $extra_label, unit => '%',
value => $out_error_prct,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-out-error'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-out-error'),
min => 0, max => 100);
}
}
$self->{statefile_value}->write(data => $new_datas);
if ($buffer_creation == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
}
$self->{output}->display();
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
}
return $value;
}
sub reload_cache {
my ($self) = @_;
my $datas = {};
$datas->{oid_filter} = $self->{option_results}->{oid_filter};
$datas->{oid_display} = $self->{option_results}->{oid_display};
$datas->{last_timestamp} = time();
$datas->{all_ids} = [];
my $result = $self->{snmp}->get_table(oid => $oids_iftable{$self->{option_results}->{oid_filter}});
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /\.([0-9]+)$/);
push @{$datas->{all_ids}}, $1;
$datas->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
}
if (scalar(@{$datas->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Can't construct cache...");
$self->{output}->option_exit();
}
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) {
$result = $self->{snmp}->get_table(oid => $oids_iftable{$self->{option_results}->{oid_display}});
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /\.([0-9]+)$/);
$datas->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
}
}
$self->{statefile_cache}->write(data => $datas);
}
sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();
}
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
my $oid_display = $self->{statefile_cache}->get(name => 'oid_display');
my $oid_filter = $self->{statefile_cache}->get(name => 'oid_filter');
if ($has_cache_file == 0 ||
($self->{option_results}->{oid_display} !~ /^($oid_display|$oid_filter)$/i || $self->{option_results}->{oid_filter} !~ /^($oid_display|$oid_filter)$/i) ||
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) {
$self->reload_cache();
$self->{statefile_cache}->read();
}
my $all_ids = $self->{statefile_cache}->get(name => 'all_ids');
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{interface})) {
# get by ID
push @{$self->{interface_id_selected}}, $self->{option_results}->{interface};
my $name = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $self->{option_results}->{interface});
if (!defined($name)) {
$self->{output}->add_option_msg(short_msg => "No interface found for id '" . $self->{option_results}->{interface} . "'.");
$self->{output}->option_exit();
}
} else {
foreach my $i (@{$all_ids}) {
my $filter_name = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_filter} . "_" . $i);
next if (!defined($filter_name));
if (!defined($self->{option_results}->{interface})) {
push @{$self->{interface_id_selected}}, $i;
next;
}
if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/i) {
push @{$self->{interface_id_selected}}, $i;
}
if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/) {
push @{$self->{interface_id_selected}}, $i;
}
if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{interface}) {
push @{$self->{interface_id_selected}}, $i;
}
}
if (scalar(@{$self->{interface_id_selected}}) <= 0) {
if (defined($self->{option_results}->{interface})) {
$self->{output}->add_option_msg(short_msg => "No interface found for name '" . $self->{option_results}->{interface} . "' (maybe you should reload cache file).");
} else {
$self->{output}->add_option_msg(short_msg => "No interface found (maybe you should reload cache file).");
}
$self->{output}->option_exit();
}
}
}
1;
__END__
=head1 MODE
=over 8
=item B<--warning-in-discard>
Threshold warning in percent for 'in' discard packets.
=item B<--critical-in-discard>
Threshold critical in percent for 'in' discard packets.
=item B<--warning-out-discard>
Threshold warning in percent for 'out' discard packets.
=item B<--critical-out-discard>
Threshold critical in percent for 'out' discard packets.
=item B<--warning-in-error>
Threshold warning in percent for 'in' error packets.
=item B<--critical-in-error>
Threshold critical in percent for 'in' error packets.
=item B<--warning-out-error>
Threshold warning in percent for 'out' error packets.
=item B<--critical-out-error>
Threshold critical in percent for 'out' error packets.
=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.
=item B<--regexp>
Allows to use regexp to filter interfaces (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
=item B<--skip>
Skip errors on interface status.
=item B<--reload-cache-time>
Time in seconds before reloading cache file (default: 180).
=item B<--oid-filter>
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--oid-display>
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
Regexp src to transform display value. (security risk!!!)
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
=item B<--show-cache>
Display cache interface datas.
=back
=cut

View File

@ -1,507 +0,0 @@
#
# Copyright 2015 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 snmp_standard::mode::traffic;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
my @operstatus = ("up", "down", "testing", "unknown", "dormant", "notPresent", "lowerLayerDown");
my %oids_iftable = (
'ifdesc' => '.1.3.6.1.2.1.2.2.1.2',
'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18',
'ifname' => '.1.3.6.1.2.1.31.1.1.1.1'
);
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 =>
{
"warning-in:s" => { name => 'warning_in' },
"critical-in:s" => { name => 'critical_in' },
"warning-out:s" => { name => 'warning_out' },
"critical-out:s" => { name => 'critical_out' },
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
"name" => { name => 'use_name' },
"interface:s" => { name => 'interface' },
"speed:s" => { name => 'speed' },
"speed-in:s" => { name => 'speed_in' },
"speed-out:s" => { name => 'speed_out' },
"skip" => { name => 'skip' },
"skip-speed0" => { name => 'skip_speed0' },
"regexp" => { name => 'use_regexp' },
"regexp-isensitive" => { name => 'use_regexpi' },
"oid-filter:s" => { name => 'oid_filter', default => 'ifname'},
"oid-display:s" => { name => 'oid_display', default => 'ifname'},
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
"show-cache" => { name => 'show_cache' },
});
$self->{interface_id_selected} = [];
$self->{get_speed} = 0;
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning-in', value => $self->{option_results}->{warning_in})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning 'in' threshold '" . $self->{option_results}->{warning_in} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-in', value => $self->{option_results}->{critical_in})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical 'in' threshold '" . $self->{option_results}->{critical_in} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning-out', value => $self->{option_results}->{warning_out})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning 'out' threshold '" . $self->{option_results}->{warning_out} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-out', value => $self->{option_results}->{critical_out})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical 'out' threshold '" . $self->{option_results}->{critical_out} . "'.");
$self->{output}->option_exit();
}
$self->{option_results}->{oid_filter} = lc($self->{option_results}->{oid_filter});
if ($self->{option_results}->{oid_filter} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-filter option.");
$self->{output}->option_exit();
}
$self->{option_results}->{oid_display} = lc($self->{option_results}->{oid_display});
if ($self->{option_results}->{oid_display} !~ /^(ifdesc|ifalias|ifname)$/) {
$self->{output}->add_option_msg(short_msg => "Unsupported --oid-display option.");
$self->{output}->option_exit();
}
if ((!defined($self->{option_results}->{speed}) || $self->{option_results}->{speed} eq '') &&
((!defined($self->{option_results}->{speed_in}) || $self->{option_results}->{speed_in} eq '') ||
(!defined($self->{option_results}->{speed_out}) || $self->{option_results}->{speed_out} eq ''))) {
$self->{get_speed} = 1;
}
$self->{statefile_cache}->check_options(%options);
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
my $oid_adminstatus = '.1.3.6.1.2.1.2.2.1.7';
my $oid_operstatus = '.1.3.6.1.2.1.2.2.1.8';
my $oid_speed32 = '.1.3.6.1.2.1.2.2.1.5'; # in b/s
my $oid_in32 = '.1.3.6.1.2.1.2.2.1.10'; # in B
my $oid_out32 = '.1.3.6.1.2.1.2.2.1.16'; # in B
my $oid_speed64 = '.1.3.6.1.2.1.31.1.1.1.15'; # need multiple by '1000000'
my $oid_in64 = '.1.3.6.1.2.1.31.1.1.1.6'; # in B
my $oid_out64 = '.1.3.6.1.2.1.31.1.1.1.10'; # in B
my $new_datas = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
foreach (@{$self->{interface_id_selected}}) {
$self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_, $oid_in32 . "." . $_, $oid_out32 . "." . $_]);
if ($self->{get_speed} == 1) {
$self->{snmp}->load(oids => [$oid_speed32 . "." . $_]);
}
if (!$self->{snmp}->is_snmpv1()) {
$self->{snmp}->load(oids => [$oid_in64 . "." . $_, $oid_out64 . "." . $_]);
if ($self->{get_speed} == 1) {
$self->{snmp}->load(oids => [$oid_speed64 . "." . $_]);
}
}
}
my $result = $self->{snmp}->get_leef();
$new_datas->{last_timestamp} = time();
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $buffer_creation = 0;
if (!defined($self->{option_results}->{interface}) || defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All traffic are ok');
}
foreach (sort @{$self->{interface_id_selected}}) {
my $display_value = $self->get_display_value(id => $_);
if ($operstatus[$result->{$oid_operstatus . "." . $_} - 1] ne "up") {
if (!defined($self->{option_results}->{skip}) && (!defined($result->{$oid_adminstatus . "." . $_}) || $operstatus[$result->{$oid_adminstatus . "." . $_} - 1] eq 'up') ) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Interface '" . $display_value . "' is not ready: " . $operstatus[$result->{$oid_operstatus . "." . $_} - 1]);
} else {
# Avoid getting "buffer creation..." alone
if (defined($self->{option_results}->{interface}) && !defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Interface '" . $display_value . "' is not up (normal state)");
}
$self->{output}->output_add(long_msg => "Skip interface '" . $display_value . "'.");
}
next;
}
# Manage interface speed
my ($interface_speed_in, $interface_speed_out);
if ($self->{get_speed} == 0) {
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
$interface_speed_in = $self->{option_results}->{speed} * 1000000;
$interface_speed_out = $self->{option_results}->{speed} * 1000000;
}
$interface_speed_in = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
$interface_speed_out = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
} else {
if ((!defined($result->{$oid_speed32 . "." . $_}) || $result->{$oid_speed32 . "." . $_} !~ /^[0-9]+$/) &&
(!defined($result->{$oid_speed64 . "." . $_}) || $result->{$oid_speed64 . "." . $_} !~ /^[0-9]+$/)) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Interface '" . $display_value . "' Speed is null or incorrect. You should force the value with --speed option");
next;
}
my $interface_speed;
if (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '') {
$interface_speed = $result->{$oid_speed64 . "." . $_} * 1000000;
# If 0, we put the 32 bits
if ($interface_speed == 0) {
$interface_speed = $result->{$oid_speed32 . "." . $_};
}
} else {
$interface_speed = $result->{$oid_speed32 . "." . $_};
}
if (!defined($interface_speed) || $interface_speed == 0) {
if (!defined($self->{option_results}->{skip_speed0})) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Interface '" . $display_value . "' Speed is 0. You should force the value with --speed option");
} else {
$self->{output}->output_add(long_msg => "Skip interface '" . $display_value . "' (speed is 0).");
}
next;
}
$interface_speed_in = $interface_speed;
$interface_speed_out = $interface_speed;
$interface_speed_in = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
$interface_speed_out = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
}
my $old_mode = $self->{statefile_value}->get(name => 'mode_' . $_);
$new_datas->{'mode_' . $_} = '32';
$new_datas->{'in_' . $_} = $result->{$oid_in32 . "." . $_};
if (defined($result->{$oid_in64 . "." . $_}) && $result->{$oid_in64 . "." . $_} ne '' && $result->{$oid_in64 . "." . $_} != 0) {
$new_datas->{'in_' . $_} = $result->{$oid_in64 . "." . $_};
$new_datas->{'mode_' . $_} = '64';
}
$new_datas->{'out_' . $_} = $result->{$oid_out32 . "." . $_};
if (defined($result->{$oid_out64 . "." . $_}) && $result->{$oid_out64 . "." . $_} ne '' && $result->{$oid_out64 . "." . $_} != 0) {
$new_datas->{'out_' . $_} = $result->{$oid_out64 . "." . $_};
$new_datas->{'mode_' . $_} = '64';
}
# Check if there is no values. Can happen :)
if (!defined($new_datas->{'out_' . $_}) || !defined($new_datas->{'in_' . $_})) {
# Avoid empty message
if (defined($self->{option_results}->{interface}) && !defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Interface '" . $display_value . "' is up");
}
$self->{output}->output_add(long_msg => "Skip interface '" . $display_value . "': bytes values are missing.");
next;
}
$new_datas->{'out_' . $_} *= 8;
$new_datas->{'in_' . $_} *= 8;
# We change mode. need to recreate a buffer
if (!defined($old_mode) || $new_datas->{'mode_' . $_} ne $old_mode) {
$buffer_creation = 1;
next;
}
my $old_in = $self->{statefile_value}->get(name => 'in_' . $_);
my $old_out = $self->{statefile_value}->get(name => 'out_' . $_);
if (!defined($old_in) || !defined($old_out)) {
$buffer_creation = 1;
next;
}
if ($new_datas->{'in_' . $_} < $old_in) {
# We set 0. Has reboot.
$old_in = 0;
}
if ($new_datas->{'out_' . $_} < $old_out) {
# We set 0. Has reboot.
$old_out = 0;
}
my $time_delta = $new_datas->{last_timestamp} - $old_timestamp;
if ($time_delta <= 0) {
# At least one second. two fast calls ;)
$time_delta = 1;
}
my $in_absolute_per_sec = ($new_datas->{'in_' . $_} - $old_in) / $time_delta;
my $out_absolute_per_sec = ($new_datas->{'out_' . $_} - $old_out) / $time_delta;
my $in_prct = $in_absolute_per_sec * 100 / $interface_speed_in;
my $out_prct = $out_absolute_per_sec * 100 / $interface_speed_out;
###########
# Manage Output
###########
my $exit1 = $self->{perfdata}->threshold_check(value => $in_prct, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $out_prct, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]);
my ($in_value, $in_unit) = $self->{perfdata}->change_bytes(value => $in_absolute_per_sec, network => 1);
my ($out_value, $out_unit) = $self->{perfdata}->change_bytes(value => $out_absolute_per_sec, network => 1);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
$self->{output}->output_add(long_msg => sprintf("Interface '%s' Traffic In : %s/s (%.2f %%), Out : %s/s (%.2f %%) ", $display_value,
$in_value . $in_unit, $in_prct,
$out_value . $out_unit, $out_prct));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{interface}) && !defined($self->{option_results}->{use_regexp}))) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Interface '%s' Traffic In : %s/s (%.2f %%), Out : %s/s (%.2f %%) ", $display_value,
$in_value . $in_unit, $in_prct,
$out_value . $out_unit, $out_prct));
}
my $extra_label = '';
$extra_label = '_' . $display_value if (!defined($self->{option_results}->{interface}) || defined($self->{option_results}->{use_regexp}));
$self->{output}->perfdata_add(label => 'traffic_in' . $extra_label, unit => 'b/s',
value => sprintf("%.2f", $in_absolute_per_sec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-in', total => $interface_speed_in),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-in', total => $interface_speed_in),
min => 0, max => $interface_speed_in);
$self->{output}->perfdata_add(label => 'traffic_out' . $extra_label, unit => 'b/s',
value => sprintf("%.2f", $out_absolute_per_sec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-out', total => $interface_speed_out),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-out', total => $interface_speed_out),
min => 0, max => $interface_speed_out);
}
$self->{statefile_value}->write(data => $new_datas);
if ($buffer_creation == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
}
$self->{output}->display();
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
}
return $value;
}
sub reload_cache {
my ($self) = @_;
my $datas = {};
$datas->{oid_filter} = $self->{option_results}->{oid_filter};
$datas->{oid_display} = $self->{option_results}->{oid_display};
$datas->{last_timestamp} = time();
$datas->{all_ids} = [];
my $result = $self->{snmp}->get_table(oid => $oids_iftable{$self->{option_results}->{oid_filter}});
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /\.([0-9]+)$/);
push @{$datas->{all_ids}}, $1;
$datas->{$self->{option_results}->{oid_filter} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
}
if (scalar(@{$datas->{all_ids}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Can't construct cache...");
$self->{output}->option_exit();
}
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}) {
$result = $self->{snmp}->get_table(oid => $oids_iftable{$self->{option_results}->{oid_display}});
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /\.([0-9]+)$/);
$datas->{$self->{option_results}->{oid_display} . "_" . $1} = $self->{output}->to_utf8($result->{$key});
}
}
$self->{statefile_cache}->write(data => $datas);
}
sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();
}
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
my $oid_display = $self->{statefile_cache}->get(name => 'oid_display');
my $oid_filter = $self->{statefile_cache}->get(name => 'oid_filter');
if ($has_cache_file == 0 ||
($self->{option_results}->{oid_display} !~ /^($oid_display|$oid_filter)$/i || $self->{option_results}->{oid_filter} !~ /^($oid_display|$oid_filter)$/i) ||
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) {
$self->reload_cache();
$self->{statefile_cache}->read();
}
my $all_ids = $self->{statefile_cache}->get(name => 'all_ids');
if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{interface})) {
# get by ID
push @{$self->{interface_id_selected}}, $self->{option_results}->{interface};
my $name = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $self->{option_results}->{interface});
if (!defined($name)) {
$self->{output}->add_option_msg(short_msg => "No interface found for id '" . $self->{option_results}->{interface} . "'.");
$self->{output}->option_exit();
}
} else {
foreach my $i (@{$all_ids}) {
my $filter_name = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_filter} . "_" . $i);
next if (!defined($filter_name));
if (!defined($self->{option_results}->{interface})) {
push @{$self->{interface_id_selected}}, $i;
next;
}
if (defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/i) {
push @{$self->{interface_id_selected}}, $i;
}
if (defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name =~ /$self->{option_results}->{interface}/) {
push @{$self->{interface_id_selected}}, $i;
}
if (!defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) && $filter_name eq $self->{option_results}->{interface}) {
push @{$self->{interface_id_selected}}, $i;
}
}
if (scalar(@{$self->{interface_id_selected}}) <= 0) {
if (defined($self->{option_results}->{interface})) {
$self->{output}->add_option_msg(short_msg => "No interface found for name '" . $self->{option_results}->{interface} . "' (maybe you should reload cache file).");
} else {
$self->{output}->add_option_msg(short_msg => "No interface found (maybe you should reload cache file).");
}
$self->{output}->option_exit();
}
}
}
1;
__END__
=head1 MODE
=over 8
=item B<--warning-in>
Threshold warning in percent for 'in' traffic.
=item B<--critical-in>
Threshold critical in percent for 'in' traffic.
=item B<--warning-out>
Threshold warning in percent for 'out' traffic.
=item B<--critical-out>
Threshold critical in percent for 'out' traffic.
=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.
=item B<--regexp>
Allows to use regexp to filter interfaces (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --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<--skip>
Skip errors on interface status.
=item B<--skip-speed0>
Skip errors on interface with speed 0.
=item B<--reload-cache-time>
Time in seconds before reloading cache file (default: 180).
=item B<--oid-filter>
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--oid-display>
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
Regexp src to transform display value. (security risk!!!)
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
=item B<--show-cache>
Display cache interface datas.
=back
=cut