From e0f99f51365fc938dab2f50404c02c5b91fe153d Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Wed, 20 Mar 2019 10:58:40 +0100 Subject: [PATCH 1/3] fix riverbed interceptor interfaces mode --- .../network/riverbed/interceptor/snmp/mode/interfaces.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm b/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm index 0e72aa30d..bd032bbad 100644 --- a/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm +++ b/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm @@ -60,7 +60,7 @@ sub set_counters { output_template => 'Packets Dropped (Software): %d packets/s', per_second => 1, perfdatas => [ - { label => 'packets_soft_dropped', value => 'interfaceSoftwareDrops', template => '%d', min => 0, + { label => 'packets_soft_dropped', value => 'interfaceSoftwareDrops_absolute', template => '%d', min => 0, unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } @@ -70,7 +70,7 @@ sub set_counters { output_template => 'XOFF Flow Control Packets Transmitted: %d packets/s', per_second => 1, perfdatas => [ - { label => 'packets_xoff', value => 'interfaceFlowCtrlPkts', template => '%d', min => 0, + { label => 'packets_xoff', value => 'interfaceFlowCtrlPkts_absolute', template => '%d', min => 0, unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, ], } From 89890802f6cea23ea54de70810ff78a1c8130d40 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Wed, 20 Mar 2019 11:17:04 +0100 Subject: [PATCH 2/3] better handling of undef --- centreon-plugins/snmp_standard/mode/memory.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/centreon-plugins/snmp_standard/mode/memory.pm b/centreon-plugins/snmp_standard/mode/memory.pm index 5b2eb4a19..0defe7513 100644 --- a/centreon-plugins/snmp_standard/mode/memory.pm +++ b/centreon-plugins/snmp_standard/mode/memory.pm @@ -259,18 +259,18 @@ sub manage_selection { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => 0); $self->{ram} = { - memTotalReal => $result->{memTotalReal} * 1024, - memAvailReal => $result->{memAvailReal} * 1024, - memTotalFree => $result->{memTotalFree} * 1024, - memShared => $result->{memShared} * 1024, - memBuffer => $result->{memBuffer} * 1024, - memCached => $result->{memCached} * 1024, + memTotalReal => ($result->{memTotalReal}) ? $result->{memTotalReal} * 1024 : 0, + memAvailReal => ($result->{memAvailReal}) ? $result->{memAvailReal} * 1024 : 0, + memTotalFree => ($result->{memTotalFree}) ? $result->{memTotalFree} * 1024 : 0, + memShared => ($result->{memShared}) ? $result->{memShared} * 1024 : 0, + memBuffer => ($result->{memBuffer}) ? $result->{memBuffer} * 1024 : 0, + memCached => ($result->{memCached}) ? $result->{memCached} * 1024 : 0, }; if (defined($self->{option_results}->{check_swap})) { $self->{swap} = { - memTotalSwap => $result->{memTotalSwap} * 1024, - memAvailSwap => $result->{memAvailSwap} * 1024, + memTotalSwap => ($result->{memTotalSwap}) ? $result->{memTotalSwap} * 1024 : 0, + memAvailSwap => ($result->{memAvailSwap}) ? $result->{memAvailSwap} * 1024 : 0, }; } } From 49ba0db5cd24aeb777d73ac096755deb6c85804b Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Wed, 20 Mar 2019 11:17:45 +0100 Subject: [PATCH 3/3] use snmp standard modes for riverbed --- .../interceptor/snmp/mode/interfaces.pm | 170 ------------------ .../riverbed/interceptor/snmp/plugin.pm | 11 +- .../network/riverbed/steelhead/snmp/plugin.pm | 8 + 3 files changed, 17 insertions(+), 172 deletions(-) delete mode 100644 centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm diff --git a/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm b/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm deleted file mode 100644 index bd032bbad..000000000 --- a/centreon-plugins/network/riverbed/interceptor/snmp/mode/interfaces.pm +++ /dev/null @@ -1,170 +0,0 @@ -# -# Copyright 2019 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::riverbed::interceptor::snmp::mode::interfaces; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'interface', type => 1, cb_prefix_output => 'prefix_interface_output', - message_multiple => 'All interfaces are ok' }, - ]; - - $self->{maps_counters}->{interface} = [ - { label => 'packets-in-dropped', set => { - key_values => [ { name => 'interfaceRxDrops', diff => 1 }, { name => 'display' } ], - output_template => 'Packets In Dropped (NIC): %d packets/s', - per_second => 1, - perfdatas => [ - { label => 'packets_in_dropped', value => 'interfaceRxDrops_absolute', template => '%d', min => 0, - unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'packets-out-dropped', set => { - key_values => [ { name => 'interfaceTxDrops', diff => 1 }, { name => 'display' } ], - output_template => 'Packets Out Dropped (NIC): %d packets/s', - per_second => 1, - perfdatas => [ - { label => 'packets_out_dropped', value => 'interfaceTxDrops_absolute', template => '%d', min => 0, - unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'packets-soft-dropped', set => { - key_values => [ { name => 'interfaceSoftwareDrops', diff => 1 }, { name => 'display' } ], - output_template => 'Packets Dropped (Software): %d packets/s', - per_second => 1, - perfdatas => [ - { label => 'packets_soft_dropped', value => 'interfaceSoftwareDrops_absolute', template => '%d', min => 0, - unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'packets-xoff', set => { - key_values => [ { name => 'interfaceFlowCtrlPkts', diff => 1 }, { name => 'display' } ], - output_template => 'XOFF Flow Control Packets Transmitted: %d packets/s', - per_second => 1, - perfdatas => [ - { label => 'packets_xoff', value => 'interfaceFlowCtrlPkts_absolute', template => '%d', min => 0, - unit => 'packets/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - ]; -} - -sub prefix_interface_output { - my ($self, %options) = @_; - - return "Interface '" . $options{instance_value}->{display} . "' "; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); - bless $self, $class; - - $self->{version} = '0.1'; - $options{options}->add_options(arguments => { - }); - return $self; -} - -my $mappings = { - int => { - interfaceName => { oid => '.1.3.6.1.4.1.17163.1.3.2.9.1.2' }, - interfaceRxDrops => { oid => '.1.3.6.1.4.1.17163.1.3.2.9.1.3' }, - interfaceTxDrops => { oid => '.1.3.6.1.4.1.17163.1.3.2.9.1.4' }, - interfaceSoftwareDrops => { oid => '.1.3.6.1.4.1.17163.1.3.2.9.1.5' }, - interfaceFlowCtrlPkts => { oid => '.1.3.6.1.4.1.17163.1.3.2.9.1.6' }, - }, -}; - -my $oids = { - int => '.1.3.6.1.4.1.17163.1.3.2.9.1', -}; - -sub manage_selection { - my ($self, %options) = @_; - - my $results = $options{snmp}->get_multiple_table( - oids => [ - { oid => $oids->{int}, - start => $mappings->{int}->{interfaceName}->{oid}, - end => $mappings->{int}->{interfaceFlowCtrlPkts}->{oid} } - ] - ); - - foreach my $equipment (keys %{$oids}) { - next if (!%{$results->{$oids->{$equipment}}}); - foreach my $oid (keys %{$results->{$oids->{$equipment}}}) { - next if ($oid !~ /^$mappings->{$equipment}->{interfaceName}->{oid}\.(\d+)/); - my $instance = $1; - - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => $instance); - - $self->{interface}->{$result->{interfaceName}} = { - display => $result->{interfaceName}, - interfaceRxDrops => $result->{interfaceRxDrops}, - interfaceTxDrops => $result->{interfaceTxDrops}, - interfaceSoftwareDrops => $result->{interfaceSoftwareDrops}, - interfaceFlowCtrlPkts => $result->{interfaceFlowCtrlPkts} - }; - } - } - - $self->{cache_name} = "riverbed_steelhead_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . - '_' . $self->{mode} . '_' . md5_hex('all'); -} - -1; - -__END__ - -=head1 MODE - -Check interfaces packets. - -=over 8 - -=item B<--warning-*> - -Threshold warning. -Can be: 'packets-in-dropped', 'packets-out-dropped', -'packets-soft-dropped', 'packets-xoff'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'packets-in-dropped', 'packets-out-dropped', -'packets-soft-dropped', 'packets-xoff'. - -=back - -=cut diff --git a/centreon-plugins/network/riverbed/interceptor/snmp/plugin.pm b/centreon-plugins/network/riverbed/interceptor/snmp/plugin.pm index ee8421b17..560c12d70 100644 --- a/centreon-plugins/network/riverbed/interceptor/snmp/plugin.pm +++ b/centreon-plugins/network/riverbed/interceptor/snmp/plugin.pm @@ -33,10 +33,17 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'interfaces' => 'network::riverbed::interceptor::snmp::mode::interfaces', + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'load' => 'snmp_standard::mode::loadaverage', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', + 'memory' => 'snmp_standard::mode::memory', 'neighbor-connections' => 'network::riverbed::interceptor::snmp::mode::neighborconnections', - 'load-average' => 'centreon::common::riverbed::steelhead::snmp::mode::loadaverage', 'status' => 'centreon::common::riverbed::steelhead::snmp::mode::status', + 'storage' => 'snmp_standard::mode::storage', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm index d6f453e02..96737822d 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm @@ -36,10 +36,18 @@ sub new { 'bandwidth-optimization' => 'centreon::common::riverbed::steelhead::snmp::mode::bwoptimization', 'bandwidth-passthrough' => 'centreon::common::riverbed::steelhead::snmp::mode::bwpassthrough', 'connections' => 'centreon::common::riverbed::steelhead::snmp::mode::connections', + 'cpu' => 'snmp_standard::mode::cpu', + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', 'disk-utilization' => 'centreon::common::riverbed::steelhead::snmp::mode::diskutilization', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', 'load-average' => 'centreon::common::riverbed::steelhead::snmp::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', 'status' => 'centreon::common::riverbed::steelhead::snmp::mode::status', + 'storage' => 'snmp_standard::mode::storage', 'temperature' => 'centreon::common::riverbed::steelhead::snmp::mode::temperature', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self;