2013-04-12 Ramon Novoa <rnovoa@artica.es>

* pandora_agent: Added macro support to all module configuration
	  tokens.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7977 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2013-04-12 13:29:23 +00:00
parent 65c4b23d76
commit 86436a134b
2 changed files with 45 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2013-04-12 Ramon Novoa <rnovoa@artica.es>
* pandora_agent: Added macro support to all module configuration
tokens.
2013-04-03 Koichiro KIKUCHI <koichiro@rworks.jp>
* pandora_agent: Adjust sleep interval so that each interval *starts*

View File

@ -496,7 +496,47 @@ sub parse_conf_modules($) {
# Make the module run the first time
$module->{'counter'} = $module->{'intensive_interval'};
# Replace macros
foreach my $token (keys (%{$module})) {
# No need to skip macros for now, since it's a hash ref and only array refs
# are searched for macros.
#if ($token eq 'macros') {
# next;
#}
# No defined value for conf token
if (! defined ($module->{$token})) {
next;
}
# Simple configuration token
if(ref($module->{$token}) eq ''){
while (my ($macro, $subst) = each (%{$module->{'macros'}})) {
eval {
$module->{$token} =~ s/$macro/$subst/g;
};
}
}
# Hash array
elsif (ref($module->{$token}) eq 'ARRAY'){
for (my $i = 0; $i <= $#{$module->{$token}}; $i++) {
# Array of configuration tokens
foreach my $key (keys ($module->{$token}->[$i])) {
# Each configuration token is a hash
while (my ($macro, $subst) = each (%{$module->{'macros'}})) {
eval {
$module->{$token}->[$i]->{$key} =~ s/$macro/$subst/g;
}
}
}
}
}
}
push (@Modules, $module);
# Plugin
} elsif ($line =~ /^\s*module_plugin\s+(.+)$/) {
@ -1312,13 +1352,6 @@ sub module_exec ($) {
return () unless ($module->{'params'} ne '');
my $params = $module->{'params'};
# If there are macros, we apply it on params
eval {
foreach my $macro (keys(%{$module->{'macros'}})) {
$params =~ s/$macro/$module->{'macros'}{$macro}/g;
}
};
# Execute the command
if ($module->{'timeout'} == 0) {