From 785390bd5402b65f190186f128a0e508a0982c6d Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Fri, 27 Jul 2012 09:05:16 +0000 Subject: [PATCH] 2012-07-27 Miguel de Dios * lib/PandoraFMS/DB.pm: added function "get_agentmodule_data" to get some data in a time period from a module. * lib/PandoraFMS/PredictionServer.pm: into the function "exec_prediction_module" avoid to fill the service modules with "subtype" SLA because this modules fill automallity after process the main modules for the service. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6823 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 10 ++++++ pandora_server/lib/PandoraFMS/DB.pm | 32 +++++++++++++++++++ .../lib/PandoraFMS/PredictionServer.pm | 12 +++++-- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2b642323bd..1d89b92ef3 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,13 @@ +2012-07-27 Miguel de Dios + + * lib/PandoraFMS/DB.pm: added function "get_agentmodule_data" to + get some data in a time period from a module. + + * lib/PandoraFMS/PredictionServer.pm: into the function + "exec_prediction_module" avoid to fill the service modules with + "subtype" SLA because this modules fill automallity after process + the main modules for the service. + 2012-07-27 KIKUCHI Koichiro * lib/PandoraFMS/Core.pm: fixed bug: added missing decode_entities for diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index cf69292e5e..a3850b78b3 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -78,6 +78,7 @@ our @EXPORT = qw( get_agent_status get_agent_modules get_agentmodule_status + get_agentmodule_data ); ########################################################################## @@ -234,6 +235,37 @@ sub get_agent_modules ($$$$$) { return @rows; } +######################################################################## +## SUB get_agentmodule_data (id_agent_module, period, date) +## Return The data for module in a period of time. +######################################################################## + +sub get_agentmodule_data ($$$$$) { + my ($pa_config, $dbh, $id_agent_module, $period, $date) = @_; + if ($date < 1) { + # Get current timestamp + $date = time (); + } + + my $datelimit = $date - $period; + + my @rows = get_db_rows($dbh, + "SELECT datos AS data, utimestamp + FROM tagente_datos + WHERE id_agente_modulo = ? + AND utimestamp > ? AND utimestamp <= ? + ORDER BY utimestamp ASC", + $id_agent_module, $datelimit, $date); + + #logger($pa_config, "SELECT datos AS data, utimestamp + # FROM tagente_datos + # WHERE id_agente_modulo = " . $id_agent_module . " + # AND utimestamp > " . $datelimit . " AND utimestamp <= " . $date . " + # ORDER BY utimestamp ASC", 1); + + return @rows; +} + ######################################################################## ## SUB get_agentmodule_status (agent_module_id) ## Return agent module status. given "agent_module_id" diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index fc0239ec9c..5d3db75aa9 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -156,9 +156,15 @@ sub exec_prediction_module ($$$$) { # Service modules if ($agent_module->{'prediction_module'} == 2) { - logger ($pa_config, "Executing service module " . $agent_module->{'nombre'}, 5); - enterprise_hook ('exec_service_module', [$pa_config, $agent_module, $server_id, $dbh]); - logger ($pa_config, "End execution", 5); + if ($agent_module->{'custom_string_1'} eq 'SLA') { + # Do none because the modules for SLA service + # are filled in the service with same id. + } + else { + logger ($pa_config, "Executing service module " . $agent_module->{'nombre'}, 5); + enterprise_hook ('exec_service_module', [$pa_config, $agent_module, $server_id, $dbh]); + logger ($pa_config, "End execution", 5); + } return; }