From 3d34e94f3a305e3646851df12984cdff9e5f1726 Mon Sep 17 00:00:00 2001 From: Andrea Cervesato Date: Mon, 14 May 2018 10:53:38 +0200 Subject: [PATCH] fix division by 0 (#64) --- connectors/vmware/src/centreon/vmware/cmdnethost.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connectors/vmware/src/centreon/vmware/cmdnethost.pm b/connectors/vmware/src/centreon/vmware/cmdnethost.pm index 8f5d64382..429a73403 100644 --- a/connectors/vmware/src/centreon/vmware/cmdnethost.pm +++ b/connectors/vmware/src/centreon/vmware/cmdnethost.pm @@ -262,8 +262,8 @@ sub run { my $packets_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.packetsTx.summation'}->{key} . ":" . $_})); my $dropped_in = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedRx.summation'}->{key} . ":" . $_})); my $dropped_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedTx.summation'}->{key} . ":" . $_})); - my $dropped_in_prct = $dropped_in * 100 / $packets_in; - my $dropped_out_prct = $dropped_out * 100 / $packets_out; + my $dropped_in_prct = ($packets_in > 0) ? $dropped_in * 100 / $packets_in : 0; + my $dropped_out_prct = ($packets_out > 0) ? $dropped_out * 100 / $packets_out : 0; my $exit3 = $self->{manager}->{perfdata}->threshold_check(value => $in_prct, threshold => [ { label => 'critical_dropped_in', exit_litteral => 'critical' }, { label => 'warning_dropped_in', exit_litteral => 'warning' } ]); my $exit4 = $self->{manager}->{perfdata}->threshold_check(value => $out_prct, threshold => [ { label => 'critical_dropped_out', exit_litteral => 'critical' }, { label => 'warning_dropped_out', exit_litteral => 'warning' } ]);