From 5c8350e70bb7825a91bac08c8e66990541a272e6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 16 May 2017 14:54:46 +0200 Subject: [PATCH] + Enhance p2000 plugin --- storage/hp/p2000/xmlapi/custom.pm | 21 +++++++++++++++++++ .../p2000/xmlapi/mode/components/sensors.pm | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/storage/hp/p2000/xmlapi/custom.pm b/storage/hp/p2000/xmlapi/custom.pm index 1ebfc7798..90d523a32 100644 --- a/storage/hp/p2000/xmlapi/custom.pm +++ b/storage/hp/p2000/xmlapi/custom.pm @@ -202,6 +202,27 @@ sub get_infos { $self->{output}->option_exit(); } + # Check if there is an error + # + #Error + #1 + #The command is ambiguous. Please check the help for this command. + #-10028 + # + # + if (my $nodestatus = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='return-code']")) { + my @nodes = $nodestatus->get_nodelist(); + my $node = shift @nodes; + my $return_code = $node->string_value; + if ($return_code != 0) { + $nodestatus = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='response']"); + @nodes = $nodestatus->get_nodelist(); + $node = shift @nodes; + $self->{output}->add_option_msg(short_msg => $node->string_value); + $self->{output}->option_exit(); + } + } + my $results = {}; foreach my $node ($nodeset->get_nodelist()) { my $properties = {}; diff --git a/storage/hp/p2000/xmlapi/mode/components/sensors.pm b/storage/hp/p2000/xmlapi/mode/components/sensors.pm index a31380fea..42520f6ce 100644 --- a/storage/hp/p2000/xmlapi/mode/components/sensors.pm +++ b/storage/hp/p2000/xmlapi/mode/components/sensors.pm @@ -67,7 +67,7 @@ sub check { my ($value, $unit); ($value, $unit) = ($1, $2) if ($results->{$sensor_id}->{value} =~ /\s*([0-9\.,]+)\s*(\S*)\s*/); - if (defined($sensor_type{$results->{$sensor_id}->{'sensor-type'}})) { + if (defined($results->{$sensor_id}->{'sensor-type'}) && defined($sensor_type{$results->{$sensor_id}->{'sensor-type'}})) { $unit = $sensor_type{$results->{$sensor_id}->{'sensor-type'}}->{unit}; }