From 04cc894573513cdc19e221a74e80083fa4fac464 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 30 Oct 2020 18:09:35 +0100 Subject: [PATCH] Fix versa (#2313) --- .../versa/director/restapi/mode/devices.pm | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/network/versa/director/restapi/mode/devices.pm b/network/versa/director/restapi/mode/devices.pm index a3f10c133..40a855380 100644 --- a/network/versa/director/restapi/mode/devices.pm +++ b/network/versa/director/restapi/mode/devices.pm @@ -341,39 +341,44 @@ sub manage_selection { device_health => {} }; - my $total = centreon::plugins::misc::convert_bytes( - value => $device->{Hardware}->{memory}, - pattern => '([0-9\.]+)(.*)$' - ); - my $free = centreon::plugins::misc::convert_bytes( - value => $device->{Hardware}->{freeMemory}, - pattern => '([0-9\.]+)(.*)$' - ); - $self->{devices}->{ $device->{name} }->{device_memory} = { - display => $device->{name}, - total => $total, - free => $free, - used => $total - $free, - prct_used => 100 - ($free * 100 / $total), - prct_free => ($free * 100 / $total) - }; + my ($total, $free); + if (defined($device->{Hardware}->{memory})) { + $total = centreon::plugins::misc::convert_bytes( + value => $device->{Hardware}->{memory}, + pattern => '([0-9\.]+)(.*)$' + ); + $free = centreon::plugins::misc::convert_bytes( + value => $device->{Hardware}->{freeMemory}, + pattern => '([0-9\.]+)(.*)$' + ); + $self->{devices}->{ $device->{name} }->{device_memory} = { + display => $device->{name}, + total => $total, + free => $free, + used => $total - $free, + prct_used => 100 - ($free * 100 / $total), + prct_free => ($free * 100 / $total) + }; + } - $total = centreon::plugins::misc::convert_bytes( - value => $device->{Hardware}->{diskSize}, - pattern => '([0-9\.]+)(.*)$' - ); - $free = centreon::plugins::misc::convert_bytes( - value => $device->{Hardware}->{freeDisk}, - pattern => '([0-9\.]+)(.*)$' - ); - $self->{devices}->{ $device->{name} }->{device_disk} = { - display => $device->{name}, - total => $total, - free => $free, - used => $total - $free, - prct_used => 100 - ($free * 100 / $total), - prct_free => ($free * 100 / $total) - }; + if (defined($device->{Hardware}->{diskSize})) { + $total = centreon::plugins::misc::convert_bytes( + value => $device->{Hardware}->{diskSize}, + pattern => '([0-9\.]+)(.*)$' + ); + $free = centreon::plugins::misc::convert_bytes( + value => $device->{Hardware}->{freeDisk}, + pattern => '([0-9\.]+)(.*)$' + ); + $self->{devices}->{ $device->{name} }->{device_disk} = { + display => $device->{name}, + total => $total, + free => $free, + used => $total - $free, + prct_used => 100 - ($free * 100 / $total), + prct_free => ($free * 100 / $total) + }; + } foreach (@{$device->{alarmSummary}->{rows}}) { $self->{devices}->{ $device->{name} }->{device_alarms}->{ lc($_->{firstColumnValue}) } = $_->{columnValues}->[0];