2013-11-12 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Completely integrated plug-ins with modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9061 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
87e9e7fc48
commit
cb8f12e1c6
|
@ -1,3 +1,7 @@
|
||||||
|
2013-11-12 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* pandora_agent: Completely integrated plug-ins with modules.
|
||||||
|
|
||||||
2013-10-21 Ramon Novoa <rnovoa@artica.es>
|
2013-10-21 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* pandora_agent_daemon: Changed status return codes to conform to LSB
|
* pandora_agent_daemon: Changed status return codes to conform to LSB
|
||||||
|
|
|
@ -450,7 +450,7 @@ sub parse_conf_modules($) {
|
||||||
$module_begin = 0;
|
$module_begin = 0;
|
||||||
|
|
||||||
# Check for invalid modules
|
# Check for invalid modules
|
||||||
next unless (($module->{'name'} ne '' && $module->{'func'} != 0) || $module->{'func'} == \&exec_plugin);
|
next unless (($module->{'name'} ne '' && $module->{'func'} != 0) || $module->{'func'} == \&module_plugin);
|
||||||
|
|
||||||
# Set the intensive interval
|
# Set the intensive interval
|
||||||
if ($module->{'is_intensive'} == 1) {
|
if ($module->{'is_intensive'} == 1) {
|
||||||
|
@ -476,7 +476,7 @@ sub parse_conf_modules($) {
|
||||||
init_module ($module);
|
init_module ($module);
|
||||||
|
|
||||||
# Configure the plugin
|
# Configure the plugin
|
||||||
$module->{'func'} = \&exec_plugin;
|
$module->{'func'} = \&module_plugin;
|
||||||
$module->{'params'} = $1;
|
$module->{'params'} = $1;
|
||||||
|
|
||||||
# Set the intensive interval
|
# Set the intensive interval
|
||||||
|
@ -491,7 +491,7 @@ sub parse_conf_modules($) {
|
||||||
|
|
||||||
push (@Modules, {%{$module}});
|
push (@Modules, {%{$module}});
|
||||||
} else {
|
} else {
|
||||||
$module->{'func'} = \&exec_plugin;
|
$module->{'func'} = \&module_plugin;
|
||||||
$module->{'params'} = $1;
|
$module->{'params'} = $1;
|
||||||
}
|
}
|
||||||
# Module proc command redefinition
|
# Module proc command redefinition
|
||||||
|
@ -1640,6 +1640,14 @@ sub write_module_xml ($@) {
|
||||||
# No data
|
# No data
|
||||||
return unless (defined $data[0]);
|
return unless (defined $data[0]);
|
||||||
|
|
||||||
|
# Is it a plugin?
|
||||||
|
if ($module->{'func'} == \&module_plugin) {
|
||||||
|
$Sem->down () if (defined ($Sem));
|
||||||
|
$Xml .= $data[0];
|
||||||
|
$Sem->up () if (defined ($Sem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# Critical section
|
# Critical section
|
||||||
$Sem->down () if (defined ($Sem));
|
$Sem->down () if (defined ($Sem));
|
||||||
|
|
||||||
|
@ -1775,29 +1783,23 @@ sub udp_server ($$) {
|
||||||
################################################################################
|
################################################################################
|
||||||
# Execute the given plugin.
|
# Execute the given plugin.
|
||||||
################################################################################
|
################################################################################
|
||||||
sub exec_plugin ($) {
|
sub module_plugin ($) {
|
||||||
my $plugin = shift;
|
my $plugin = shift;
|
||||||
|
|
||||||
my $command = $plugin->{'params'};
|
my $command = $plugin->{'params'};
|
||||||
|
|
||||||
# Empty plugin
|
# Empty plugin
|
||||||
return if ($command eq '');
|
return () if ($command eq '');
|
||||||
|
|
||||||
# Execute the plugin
|
# Execute the plugin
|
||||||
my $output = `$command 2>$DevNull`;
|
my $output = `$command 2>$DevNull`;
|
||||||
|
|
||||||
# Do not save the output if there was an error
|
# Do not save the output if there was an error
|
||||||
if ($? != 0) {
|
if ($? != 0) {
|
||||||
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
|
return ();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Critical section
|
return ($output);
|
||||||
$Sem->down () if (defined ($Sem));
|
|
||||||
$Xml .= $output;
|
|
||||||
$Sem->up () if (defined ($Sem));
|
|
||||||
|
|
||||||
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -2136,13 +2138,10 @@ while (1) {
|
||||||
# Execute modules
|
# Execute modules
|
||||||
foreach my $module (@Modules) {
|
foreach my $module (@Modules) {
|
||||||
|
|
||||||
# Is it a plugin?
|
|
||||||
my $exec_func = ($module->{'func'} == \&exec_plugin) ? \&exec_plugin : \&exec_module;
|
|
||||||
|
|
||||||
# Execute the module in a separate thread
|
# Execute the module in a separate thread
|
||||||
if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1) {
|
if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1) {
|
||||||
$ThreadSem->down ();
|
$ThreadSem->down ();
|
||||||
my $thr = threads->create ($exec_func, $module);
|
my $thr = threads->create (\&exec_module, $module);
|
||||||
if (! defined ($thr)) {
|
if (! defined ($thr)) {
|
||||||
$ThreadSem->up ();
|
$ThreadSem->up ();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2150,7 +2149,7 @@ while (1) {
|
||||||
}
|
}
|
||||||
# Execute the module
|
# Execute the module
|
||||||
} else {
|
} else {
|
||||||
$exec_func->($module);
|
exec_module($module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue