+ Minor fix protection

This commit is contained in:
Quentin Garnier 2015-01-09 12:01:07 +01:00
parent 57f361c88c
commit fd0334cc90
2 changed files with 4 additions and 1 deletions

View File

@ -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);

View File

@ -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;
}