mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
2012-08-01 Sergio Martin <sergio.martin@artica.es>
* pandora_agent: Add the macros support in module_exec git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6838 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ca415287d9
commit
af1fc6eba3
@ -1,3 +1,7 @@
|
|||||||
|
2012-08-01 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* pandora_agent: Add the macros support in module_exec
|
||||||
|
|
||||||
2012-06-27 Koichiro Kikuchi <koichiro@rworks.jp>
|
2012-06-27 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||||
|
|
||||||
* pandora_agent.redhat.spec: Merged from 4.0 branch. Don't create
|
* pandora_agent.redhat.spec: Merged from 4.0 branch. Don't create
|
||||||
|
@ -30,6 +30,7 @@ use File::Basename;
|
|||||||
use File::Copy;
|
use File::Copy;
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
|
|
||||||
|
|
||||||
# Agent XML data
|
# Agent XML data
|
||||||
my $Xml;
|
my $Xml;
|
||||||
|
|
||||||
@ -373,6 +374,7 @@ sub parse_conf_modules($) {
|
|||||||
'intensive_match' => 0,
|
'intensive_match' => 0,
|
||||||
'timestamp' => 0,
|
'timestamp' => 0,
|
||||||
'unit' => '',
|
'unit' => '',
|
||||||
|
'macros' => {},
|
||||||
};
|
};
|
||||||
} elsif ($line =~ /^\s*module_name\s+(.+)$/) {
|
} elsif ($line =~ /^\s*module_name\s+(.+)$/) {
|
||||||
$module->{'name'} = $1;
|
$module->{'name'} = $1;
|
||||||
@ -530,6 +532,9 @@ sub parse_conf_modules($) {
|
|||||||
# Unit
|
# Unit
|
||||||
} elsif ($line =~ /^\s*module_unit\s+(\S+)\s*$/) {
|
} elsif ($line =~ /^\s*module_unit\s+(\S+)\s*$/) {
|
||||||
$module->{'unit'} = $1;
|
$module->{'unit'} = $1;
|
||||||
|
# Macros
|
||||||
|
} elsif ($line =~ /^\s*module_macro(\S+)\s+(\S+)\s*$/) {
|
||||||
|
$module->{'macros'}{$1} = $2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1255,11 +1260,20 @@ sub module_exec ($) {
|
|||||||
# Check module parameters
|
# Check module parameters
|
||||||
return () unless ($module->{'params'} ne '');
|
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
|
# Execute the command
|
||||||
if ($module->{'timeout'} == 0) {
|
if ($module->{'timeout'} == 0) {
|
||||||
@data = `$module->{'params'} 2> $DevNull`;
|
@data = `$params 2> $DevNull`;
|
||||||
} else {
|
} else {
|
||||||
my $cmd = quotemeta ($module->{'params'});
|
my $cmd = quotemeta ($params);
|
||||||
@data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> $DevNull`;
|
@data = `$Conf{'pandora_exec'} $module->{'timeout'} $cmd 2> $DevNull`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user