+ Fix #663
This commit is contained in:
parent
b2f9a910c5
commit
812e3c4aa8
|
@ -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);
|
||||
|
|
|
@ -49,20 +49,30 @@ sub check {
|
|||
key => 'sensor-name',
|
||||
properties_name => '^(value|sensor-type|status)$');
|
||||
|
||||
#<OBJECT basetype="sensors" name="sensor" oid="22" format="rows">
|
||||
# <PROPERTY name="sensor-name" key="true" type="string" size="33" draw="true" sort="string" display-name="Sensor Name">Capacitor Charge-Ctlr B</PROPERTY>
|
||||
# <PROPERTY name="value" type="string" size="8" draw="true" sort="string" display-name="Value">100%</PROPERTY>
|
||||
# <PROPERTY name="status" type="string" size="8" draw="true" sort="string" display-name="Status">OK</PROPERTY>
|
||||
#</OBJECT>
|
||||
#<OBJECT basetype="sensors" name="sensor" oid="23" format="rows">
|
||||
# <PROPERTY name="sensor-name" key="true" type="string" size="33" draw="true" sort="string" display-name="Sensor Name">Overall Unit Status</PROPERTY>
|
||||
# <PROPERTY name="value" type="string" size="8" draw="true" sort="string" display-name="Value">Warning</PROPERTY>
|
||||
# <PROPERTY name="status" type="string" size="8" draw="true" sort="string" display-name="Status">Warning</PROPERTY>
|
||||
#</OBJECT>
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue