From 812e3c4aa8b6d582cde6ceb346f26c433ccc04c1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 16 May 2017 11:29:35 +0200 Subject: [PATCH] + Fix #663 --- storage/hp/p2000/xmlapi/custom.pm | 6 ++++-- .../hp/p2000/xmlapi/mode/components/sensors.pm | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/storage/hp/p2000/xmlapi/custom.pm b/storage/hp/p2000/xmlapi/custom.pm index 3aa80740f..1ebfc7798 100644 --- a/storage/hp/p2000/xmlapi/custom.pm +++ b/storage/hp/p2000/xmlapi/custom.pm @@ -178,7 +178,8 @@ sub DESTROY { if ($self->{logon} == 1) { $self->{http}->request(url_path => $self->{url_path} . 'exit', - header => ['dataType: api', 'sessionKey: ' . $self->{session_id}]); + header => ['Cookie: wbisessionkey=' . $self->{session_id} . '; wbiusername=' . $self->{username}, + 'dataType: api', 'sessionKey: '. $self->{session_id}]); } } @@ -189,7 +190,8 @@ sub get_infos { my $cmd = $options{cmd}; $cmd =~ s/ /\//g; my $response =$self->{http}->request(url_path => $self->{url_path} . $cmd, - header => ['dataType: api', 'sessionKey: '. $self->{session_id}]); + header => ['Cookie: wbisessionkey=' . $self->{session_id} . '; wbiusername=' . $self->{username}, + 'dataType: api', 'sessionKey: '. $self->{session_id}]); eval { $xpath = XML::XPath->new(xml => $response); diff --git a/storage/hp/p2000/xmlapi/mode/components/sensors.pm b/storage/hp/p2000/xmlapi/mode/components/sensors.pm index 142aca58b..a31380fea 100644 --- a/storage/hp/p2000/xmlapi/mode/components/sensors.pm +++ b/storage/hp/p2000/xmlapi/mode/components/sensors.pm @@ -49,20 +49,30 @@ sub check { key => 'sensor-name', properties_name => '^(value|sensor-type|status)$'); + # + # Capacitor Charge-Ctlr B + # 100% + # OK + # + # + # Overall Unit Status + # Warning + # Warning + # foreach my $sensor_id (keys %$results) { next if ($self->check_exclude(section => 'sensor', instance => $sensor_id)); $self->{components}->{sensor}->{total}++; my $state = $results->{$sensor_id}->{status}; - $results->{$sensor_id}->{value} =~ /\s*([0-9\.,]+)\s*(\S*)\s*/; - my ($value, $unit) = ($1, $2); + 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'}})) { $unit = $sensor_type{$results->{$sensor_id}->{'sensor-type'}}->{unit}; } $self->{output}->output_add(long_msg => sprintf("sensor '%s' status is %s (value: %s %s).", - $sensor_id, $state, $value, $unit) + $sensor_id, $state, defined($value) ? $value : '-', defined($unit) ? $unit : '-') ); foreach (@conditions) { if ($state =~ /$$_[0]/i) { @@ -74,7 +84,7 @@ sub check { } $self->{output}->perfdata_add(label => $sensor_id, unit => $unit, - value => $value); + value => $value) if (defined($value)); } }