+ Enhance p2000 plugin

This commit is contained in:
garnier-quentin 2017-05-16 14:54:46 +02:00
parent e1ecbaa9be
commit cdba79cd70
2 changed files with 22 additions and 1 deletions

View File

@ -202,6 +202,27 @@ sub get_infos {
$self->{output}->option_exit();
}
# Check if there is an error
#<OBJECT basetype="status" name="status" oid="1">
#<PROPERTY name="response-type" type="enumeration" size="12" draw="false" sort="nosort" display-name="Response Type">Error</PROPERTY>
#<PROPERTY name="response-type-numeric" type="enumeration" size="12" draw="false" sort="nosort" display-name="Response">1</PROPERTY>
#<PROPERTY name="response" type="string" size="180" draw="true" sort="nosort" display-name="Response">The command is ambiguous. Please check the help for this command.</PROPERTY>
#<PROPERTY name="return-code" type="int32" size="5" draw="false" sort="nosort" display-name="Return Code">-10028</PROPERTY>
#<PROPERTY name="component-id" type="string" size="80" draw="false" sort="nosort" display-name="Component ID"></PROPERTY>
#</OBJECT>
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 = {};

View File

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