From 12f41d0438fd5957b32d325594a88a0288e03e82 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 29 Jul 2015 10:04:08 +0200 Subject: [PATCH] + Enhance interface speed result for list-interfaces --- snmp_standard/mode/listinterfaces.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/snmp_standard/mode/listinterfaces.pm b/snmp_standard/mode/listinterfaces.pm index b11c694f4..91ea303d1 100644 --- a/snmp_standard/mode/listinterfaces.pm +++ b/snmp_standard/mode/listinterfaces.pm @@ -91,7 +91,8 @@ sub run { foreach (sort @{$self->{interface_id_selected}}) { my $display_value = $self->get_display_value(id => $_); - my $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' ? ($result->{$oid_speed64 . "." . $_}) : (int($result->{$oid_speed32 . "." . $_} / 1000 / 1000))); + my $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0 ? + ($result->{$oid_speed64 . "." . $_}) : (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000))); if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { $interface_speed = $self->{option_results}->{speed}; } @@ -223,7 +224,8 @@ sub disco_show { foreach (sort @{$self->{interface_id_selected}}) { my $display_value = $self->get_display_value(id => $_); - my $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0 ? ($result->{$oid_speed64 . "." . $_}) : (int($result->{$oid_speed32 . "." . $_} / 1000 / 1000))); + my $interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' && $result->{$oid_speed64 . "." . $_} != 0 ? + ($result->{$oid_speed64 . "." . $_}) : (sprintf("%g", $result->{$oid_speed32 . "." . $_} / 1000 / 1000))); if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { $interface_speed = $self->{option_results}->{speed}; }