2008-07-30 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/DB.pm,
          bin/pandora_wmi: Small fixes.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@984 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2008-07-30 14:21:11 +00:00
parent fe220658c2
commit 9aa0c8c85e
3 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2008-07-30 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm,
bin/pandora_wmi: Small fixes.
2008-07-30 Sancho Lerena <slerena@gmail.com>
* lib/PandoraFMS/DB.pm: FIXED a stupid bug that makes impossible to

View File

@ -54,6 +54,13 @@ $SIG{'INT'} = 'pandora_shutdown';
# Inicio del bucle principal de programa
pandora_init(\%pa_config, "Pandora FMS WMI Server");
# Check for wmic
my $wmi_client = "wmic";
if (system("$wmi_client > /dev/null 2>&1") != 256) {
print " [E] $wmi_client not found. Pandora FMS WMI Server needs a DCOM/WMI client.\n\n";
exit;
}
# Read config file for Global variables
pandora_loadconfig (\%pa_config, 6);
@ -257,7 +264,7 @@ sub pandora_wmi_producer ($) {
tagente, tagente_modulo, tagente_estado, tserver
WHERE
( (tagente.id_wmi_server = $server_id AND tagente_modulo.id_agente = tagente.id_agente) OR
(tagente.id_wmi_server != $server_id AND tagente_modulo.id_agente = tagente.id_agente AND tagente.id_plugin_server = tserver.id_server AND tserver.status = 0)
(tagente.id_wmi_server != $server_id AND tagente_modulo.id_agente = tagente.id_agente AND tagente.id_wmi_server = tserver.id_server AND tserver.status = 0)
) AND
tagente.disabled = 0
AND
@ -307,7 +314,7 @@ sub exec_wmi_module {
my $dbh = $_[2];
# Set global variables for this sub
my $timeout = $pa_config->{'plugin_timeout'};
my $timeout = $pa_config->{'wmi_timeout'};
my $agent_module; # hash container for tagente_modulo record
# Get a full hash for agent_plugin record reference ($agent_module)
@ -328,9 +335,6 @@ sub exec_wmi_module {
my $module_interval = 0;
# Build execution command to plugin
my $exec_output = "";
my $wmi_command = "wmic ";
# Sample exec: wmic -U Administrador%none //192.168.50.123 "SELECT State FROM Win32_Service WHERE Name = \"Eventlog\""
# This returns several lines that needs to be processed
@ -342,7 +346,7 @@ sub exec_wmi_module {
my $wmi_query = decode_entities($agent_module->{'snmp_oid'});
$wmi_query =~ s/\"/\'/g;
$wmi_command .= " -U \"". $agent_module->{'plugin_user'} ."\"%\"". $agent_module->{'plugin_pass'} . "\"";
my $wmi_command = "$wmi_client -U \"". $agent_module->{'plugin_user'} ."\"%\"". $agent_module->{'plugin_pass'} . "\"";
$wmi_command .= " //". $agent_module->{'ip_target'};
$wmi_command .= " \"". $wmi_query . "\"";
logger ($pa_config, "Executing AM # $id_am WMI command '$wmi_command'", 9);

View File

@ -24,6 +24,7 @@ use Time::Format qw(%time %strftime %manip); # For data mangling
use DBI;
use Date::Manip; # Needed to manipulate DateTime formats of input, output and compare
use XML::Simple;
use HTML::Entities;
use POSIX qw(strtod);
@ -520,7 +521,7 @@ sub execute_alert (%$$$$$$$$$$$$$$$) {
$command =~ s/_timestamp_/$timestamp/ig;
$command =~ s/_data_/$data/ig;
# Clean up some "tricky" characters
$command =~ s/&gt;/>/g;
$command = decode_entities($command);
# EXECUTING COMMAND !!!
eval {
my $exit_value = system ($command);