From 0f04a5693f6156de217462bdbde1c6755aea5508 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 5 Sep 2013 09:57:40 +0000 Subject: [PATCH] 2013-09-05 Miguel de Dios * lib/PandoraFMS/PluginServer.pm: fixed the lost decode html entities for the value in the macros. * util/plugin/dummy_plugin.pl: added tiny plugin server with only purpose to testing. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8744 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/lib/PandoraFMS/PluginServer.pm | 14 ++++++++------ pandora_server/util/plugin/dummy_plugin.pl | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100755 pandora_server/util/plugin/dummy_plugin.pl diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index e079044134..72abf2b692 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2013-09-05 Miguel de Dios + + * lib/PandoraFMS/PluginServer.pm: fixed the lost decode html + entities for the value in the macros. + + * util/plugin/dummy_plugin.pl: added tiny plugin server with only + purpose to testing. + 2013-09-04 Ramon Novoa * lib/PandoraFMS/Core.pm, diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index efe60b0b8b..2e34e15472 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -162,17 +162,17 @@ sub data_consumer ($$) { # Build command to execute my $command = $plugin->{'execute'}; - + if (!defined($plugin->{'parameters'})){ $plugin->{'parameters'} = ""; } my $parameters = $plugin->{'parameters'}; - + if (!defined($module->{'macros'})){ $module->{'macros'} = ""; } - + # Plugin macros eval { if ($module->{'macros'} ne '') { @@ -182,7 +182,9 @@ sub data_consumer ($$) { if(ref($macros) eq "HASH") { foreach my $macro_id (keys(%macros)) { - $parameters =~ s/$macros{$macro_id}{'macro'}/$macros{$macro_id}{'value'}/g; + my $macro_value = safe_output($macros{$macro_id}{'value'}); + + $parameters =~ s/$macros{$macro_id}{'macro'}/$macro_value/g; } } } @@ -215,13 +217,13 @@ sub data_consumer ($$) { $command .= ' ' . $parameters; - $command = decode_entities($command); + $command = safe_output($command); logger ($pa_config, "Executing AM # $module_id plugin command '$command'", 9); # Execute command $command = $pa_config->{'plugin_exec'} . ' ' . $timeout . ' ' . $command; - + my $module_data; eval { $module_data = `$command`; diff --git a/pandora_server/util/plugin/dummy_plugin.pl b/pandora_server/util/plugin/dummy_plugin.pl new file mode 100755 index 0000000000..996eef1d5b --- /dev/null +++ b/pandora_server/util/plugin/dummy_plugin.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Data::Dumper; + +open STDOUT, '>', "/var/log/pandora/pandora_server.log"; + +print "------------INIT DUMMY PLUGIN------------------\n"; +print Dumper(@ARGV) . "\n"; +print "------------END DUMMY PLUGIN------------------\n"; + +close(STDOUT); + +exit 1; \ No newline at end of file