From fd0334cc90e3f49e30d86cb6329de523b5fbde7f Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Fri, 9 Jan 2015 12:01:07 +0100 Subject: [PATCH] + Minor fix protection --- connectors/vmware/src/centreon/esxd/cmdmemvm.pm | 3 ++- connectors/vmware/src/centreon/esxd/common.pm | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/connectors/vmware/src/centreon/esxd/cmdmemvm.pm b/connectors/vmware/src/centreon/esxd/cmdmemvm.pm index 83a0adbad..deb9cd552 100644 --- a/connectors/vmware/src/centreon/esxd/cmdmemvm.pm +++ b/connectors/vmware/src/centreon/esxd/cmdmemvm.pm @@ -124,6 +124,7 @@ sub run { multiple => $multiple) == 0); my $entity_value = $entity_view->{mo_ref}->{value}; my $memory_size = $entity_view->{'summary.config.memorySizeMB'} * 1024 * 1024; + # in KB my $mem_consumed = centreon::esxd::common::simplify_number(centreon::esxd::common::convert_number($values->{$entity_value}->{$self->{obj_esxd}->{perfcounter_cache}->{'mem.consumed.average'}->{'key'} . ":"}[0])) * 1024; my $mem_active = centreon::esxd::common::simplify_number(centreon::esxd::common::convert_number($values->{$entity_value}->{$self->{obj_esxd}->{perfcounter_cache}->{'mem.active.average'}->{'key'} . ":"}[0])) * 1024; @@ -135,7 +136,7 @@ sub run { my $prct_used = $mem_consumed * 100 / $memory_size; my $prct_free = 100 - $prct_used; - my $exit = $self->{manager}->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{manager}->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_value, $total_unit) = $self->{manager}->{perfdata}->change_bytes(value => $memory_size); my ($used_value, $used_unit) = $self->{manager}->{perfdata}->change_bytes(value => $mem_consumed); my ($free_value, $free_unit) = $self->{manager}->{perfdata}->change_bytes(value => $mem_free); diff --git a/connectors/vmware/src/centreon/esxd/common.pm b/connectors/vmware/src/centreon/esxd/common.pm index ec3b9e6ac..abc0a7139 100644 --- a/connectors/vmware/src/centreon/esxd/common.pm +++ b/connectors/vmware/src/centreon/esxd/common.pm @@ -127,6 +127,8 @@ sub simplify_number { sub convert_number { my ($number) = shift(@_); + # Avoid error counter empty. But should manage it in code the 'undef'. + $number = 0 if (!defined($number)); $number =~ s/\,/\./; return $number; }