2008-08-01 Ramon Novoa <rnovoa@artica.es>
* bin/pandora_wmi: Removed the timeout mechanism. * bin/pandora_plugin: Removed the timeout mechanism. pandora_exec is used instead. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@996 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
53a23dbbb6
commit
950d4a3b98
|
@ -1,3 +1,9 @@
|
||||||
|
2008-08-01 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* bin/pandora_wmi: Removed the timeout mechanism.
|
||||||
|
* bin/pandora_plugin: Removed the timeout mechanism. pandora_exec is
|
||||||
|
used instead.
|
||||||
|
|
||||||
2008-07-31 Ramon Novoa <rnovoa@artica.es>
|
2008-07-31 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* util/pandora_exec: Added to repository. Perl script to control
|
* util/pandora_exec: Added to repository. Perl script to control
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Date::Manip; # Needed to manipulate DateTime formats of input, output
|
||||||
use Time::Local; # DateTime basic manipulation
|
use Time::Local; # DateTime basic manipulation
|
||||||
use threads;
|
use threads;
|
||||||
use threads::shared;
|
use threads::shared;
|
||||||
|
use HTML::Entities;
|
||||||
|
|
||||||
# Pandora Modules
|
# Pandora Modules
|
||||||
use PandoraFMS::Config;
|
use PandoraFMS::Config;
|
||||||
|
@ -54,6 +55,13 @@ $SIG{'INT'} = 'pandora_shutdown';
|
||||||
# Inicio del bucle principal de programa
|
# Inicio del bucle principal de programa
|
||||||
pandora_init(\%pa_config, "Pandora FMS Plugin Server");
|
pandora_init(\%pa_config, "Pandora FMS Plugin Server");
|
||||||
|
|
||||||
|
# Check for pandora_exec
|
||||||
|
my $pandora_exec = "pandora_exec";
|
||||||
|
if (system("$pandora_exec > /dev/null 2>&1") != 256) {
|
||||||
|
print " [E] $pandora_exec not found.\n\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
# Read config file for Global variables
|
# Read config file for Global variables
|
||||||
pandora_loadconfig (\%pa_config, 4);
|
pandora_loadconfig (\%pa_config, 4);
|
||||||
|
|
||||||
|
@ -330,28 +338,23 @@ sub exec_plugin_module {
|
||||||
if ($agent_module->{'plugin_parameter'} ne "") {
|
if ($agent_module->{'plugin_parameter'} ne "") {
|
||||||
$plugin_command = $plugin_command . " ". $agent_module->{'plugin_parameter'};
|
$plugin_command = $plugin_command . " ". $agent_module->{'plugin_parameter'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$plugin_command = decode_entities($plugin_command);
|
||||||
|
|
||||||
logger ($pa_config, "Executing AM # $id_am plugin command '$plugin_command'", 9);
|
logger ($pa_config, "Executing AM # $id_am plugin command '$plugin_command'", 9);
|
||||||
# Final command line execution is stored at "plugin_command"
|
# Final command line execution is stored at "plugin_command"
|
||||||
eval {
|
|
||||||
alarm ($timeout);
|
|
||||||
$module_data = `$plugin_command`;
|
|
||||||
alarm(0); # Cancel the pending alarm if plugin call returns alive
|
|
||||||
$module_result = 0; # If comes here, this is a successfull exec
|
|
||||||
};
|
|
||||||
|
|
||||||
# Timeout
|
$module_data = `$pandora_exec $timeout $plugin_command`;
|
||||||
if ($@ =~ /PANDORA PLUGIN SERVER TIMED OUT/) {
|
if ($module_data eq "") {
|
||||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_module->{'id_agente_modulo'}." causes a system timeout in exec", 1);
|
$module_result = 1;
|
||||||
logger ($pa_config, "Executing plugin command '$plugin_command'", 9);
|
} else {
|
||||||
|
$module_result = 0;
|
||||||
# General error, not timed-out
|
|
||||||
} elsif ($module_result == 1) {
|
|
||||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_module->{'id_agente_modulo'}." causes an unknown system error", 1);
|
|
||||||
logger ($pa_config, "[ERROR] $@", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub timed_out {
|
# Error
|
||||||
die "PANDORA PLUGIN SERVER TIMED OUT";
|
if ($module_result == 1) {
|
||||||
|
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_module->{'id_agente_modulo'}." causes an unknown system error", 1);
|
||||||
|
logger ($pa_config, "[ERROR] $@", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get current timestamp
|
# Get current timestamp
|
||||||
|
|
|
@ -351,8 +351,6 @@ sub exec_wmi_module {
|
||||||
$wmi_command .= " \"". $wmi_query . "\"";
|
$wmi_command .= " \"". $wmi_query . "\"";
|
||||||
logger ($pa_config, "Executing AM # $id_am WMI command '$wmi_command'", 9);
|
logger ($pa_config, "Executing AM # $id_am WMI command '$wmi_command'", 9);
|
||||||
|
|
||||||
eval {
|
|
||||||
alarm ($timeout);
|
|
||||||
$module_data = `$wmi_command`;
|
$module_data = `$wmi_command`;
|
||||||
my @data = split("\n", $module_data);
|
my @data = split("\n", $module_data);
|
||||||
my @data2 = split(/\|/, $data[2]); # get third line (containing data)
|
my @data2 = split(/\|/, $data[2]); # get third line (containing data)
|
||||||
|
@ -361,7 +359,6 @@ sub exec_wmi_module {
|
||||||
# field from tagente_module table.
|
# field from tagente_module table.
|
||||||
|
|
||||||
$module_data = $data2[$agent_module -> {'tcp_port'}];
|
$module_data = $data2[$agent_module -> {'tcp_port'}];
|
||||||
alarm(0); # Cancel the pending alarm if plugin call returns alive
|
|
||||||
|
|
||||||
# Look for errors
|
# Look for errors
|
||||||
if ($module_data =~ /ERROR/) {
|
if ($module_data =~ /ERROR/) {
|
||||||
|
@ -382,23 +379,13 @@ sub exec_wmi_module {
|
||||||
$module_data = 0;
|
$module_data = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
# Timeout
|
# Error
|
||||||
if ($@ =~ /PANDORA WMI SERVER TIMED OUT/) {
|
if ($module_result == 1) {
|
||||||
logger ($pa_config, "[ERROR] WMI Task for module ".$agent_module->{'id_agente_modulo'}." causes a system timeout in exec", 1);
|
|
||||||
logger ($pa_config, "Executing WMI command '$wmi_command'", 9);
|
|
||||||
|
|
||||||
# General error, not timed-out
|
|
||||||
} elsif ($module_result == 1) {
|
|
||||||
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_module->{'id_agente_modulo'}." causes an unknown system error", 1);
|
logger ($pa_config, "[ERROR] Plugin Task for module ".$agent_module->{'id_agente_modulo'}." causes an unknown system error", 1);
|
||||||
logger ($pa_config, "[ERROR] $@", 1);
|
logger ($pa_config, "[ERROR] $@", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub timed_out {
|
|
||||||
die "PANDORA WMI SERVER TIMED OUT";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get current timestamp
|
# Get current timestamp
|
||||||
my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S");
|
my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S");
|
||||||
my $utimestamp = &UnixDate("today","%s");
|
my $utimestamp = &UnixDate("today","%s");
|
||||||
|
|
Loading…
Reference in New Issue