diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index 3606166508..0733f20f4c 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -203,11 +203,30 @@ sub data_consumer ($$) { my @row = split(/\|/, $output[2]); # Get the specified column - $module_data = $row[$module->{'tcp_port'}] if (defined ($module->{'tcp_port'}) && defined ($row[$module->{'tcp_port'}])); - if ($module_data =~ m/^ERROR/) { - pandora_update_module_on_error ($pa_config, $module, $dbh); - return; - } + if (defined ($module->{'tcp_port'})) { + $wmi_query =~ m/SELECT\s(.+)\sFROM/ig; + my @wmi_columns = split /\s*,\s*/, $1; + my $selected_col = $wmi_columns[$module->{'tcp_port'}]; + + # Get result col number + my @output_col = split(/\|/, $output[1]); + + # Find column number + my $col_number; + + for(my $i = 0; $i < @output_col; $i++ ) { + if( $output_col[$i] =~ /$selected_col/ ) { + $col_number = $i; + last; + } + } + + $module_data = $row[$col_number] if (defined ($col_number) && defined ($row[$col_number])); + if ($module_data =~ m/^ERROR/) { + pandora_update_module_on_error ($pa_config, $module, $dbh); + return; + } + } # Regexp if ($module->{'snmp_community'} ne ''){