diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index b5ed236fe2..b4fa2d14c3 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,8 @@ +2012-11-15 Sergio Martin + + * pandora_agent: Added support to the new fields of the + agent in the XML: custom_id, url_addres and custom fields + 2012-11-13 Sergio Martin * pandora_agent: Added several fields to the XML diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index b117d2b598..7088cbd60d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -157,6 +157,8 @@ my %Conf = ( 'intensive_interval' => 0, 'timestamp' => 0, 'xml_buffer' => 0, + 'custom_id' => '', + 'url_address' => '', ); # Modules @@ -190,6 +192,9 @@ my %Parts = ( # Collections my %Collections; +# Custom fields +my %Customfields; + # $DevNull my $DevNull = '/dev/null'; @@ -337,7 +342,6 @@ sub parse_conf_modules($) { 'description' => '', 'func' => 0, 'params' => '', - 'description' => '', 'interval' => 1, 'timeout' => 0, 'counter' => 0, @@ -624,10 +628,17 @@ sub read_config (;$) { foreach my $line (@file){ # Skip comments and empty lines next if ($line =~ m/^\s*#/) or ($line =~ m/^\s*$/); - + # Replace CRLF with LF $line =~ s/\r\n/\n/g; + # Store the custom fields + + if (($line =~ m/^(custom_field\d+_name)\s+(.*)/) or ($line =~ m/^(custom_field\d+_value)\s+(.*)/)) { + $Customfields{$1} = $2; + next; + } + # Token search if (defined ($token)) { if ($line =~ /^\s*(\S+)\s+(.*)$/ && $1 eq $token) { @@ -1989,6 +2000,24 @@ while (1) { # Clear the XML $Xml = ""; + # Custom fields + + my @customfieldskeys = keys(%Customfields); + if ($#customfieldskeys > -1) { + $Xml .= "\n"; + foreach my $customfieldkey (@customfieldskeys) { + if($customfieldkey =~ m/^(custom_field\d+_)name/) { + if(defined($Customfields{$1."value"})) { + $Xml .= " \n"; + $Xml .= " \n"; + $Xml .= " \n"; + $Xml .= " \n"; + } + } + } + $Xml .= "\n"; + } + # Execute modules foreach my $module (@Modules) { @@ -2041,7 +2070,8 @@ while (1) { "