From 1faca416fd30c9aa5688ae920e7dd1e7e4a8948e Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 3 Feb 2012 12:31:08 +0000 Subject: [PATCH] 2012-02-03 Ramon Novoa * lib/PandoraFMS/Core.pm: Added support for ff interval. Small improvements. * lib/PandoraFMS/DataServer.pm: Added "timestamp" to the list of valid XML tags. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5484 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/lib/PandoraFMS/Core.pm | 18 +++++++++++++++--- pandora_server/lib/PandoraFMS/DataServer.pm | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 824abcc3d7..4c10866956 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2012-02-03 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Added support for ff interval. Small + improvements. + + * lib/PandoraFMS/DataServer.pm: Added "timestamp" to the list of + valid XML tags. + 2012-02-01 Ramon Novoa * conf/pandora_server.conf, diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 03cb54b0a7..05b3b29c70 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -895,15 +895,28 @@ sub pandora_process_module ($$$$$$$$$;$) { # Get new status my $new_status = get_module_status ($processed_data, $module, $module_type); + # Calculate the current interval + my $current_interval = ($module->{'module_interval'} == 0 ? $agent->{'intervalo'} : $module->{'module_interval'}); + #Update module status my $current_utimestamp = time (); if ($last_status == $new_status) { + + # Avoid overflows + $status_changes = $module->{'min_ff_event'} if ($status_changes > $module->{'min_ff_event'}); + $status_changes++; } else { $status_changes = 0; } - if ($status_changes == $module->{'min_ff_event'}) { + # Active ff interval + if ($module->{'module_ff_interval'} != 0 && $status_changes < $module->{'min_ff_event'}) { + $current_interval = $module->{'module_ff_interval'}; + } + + # Change status + if ($status_changes == $module->{'min_ff_event'} && $status != $new_status) { generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $dbh); $status = $new_status; } @@ -929,8 +942,7 @@ sub pandora_process_module ($$$$$$$$$;$) { my $last_try = ($1 == 0) ? 0 : timelocal($6, $5, $4, $3, $2 - 1, $1 - 1900); my $save = ($module->{'history_data'} == 1 && ($agent_status->{'datos'} ne $processed_data || $last_try < ($utimestamp - 86400))) ? 1 : 0; - - my $current_interval = ($module->{'module_interval'} == 0 ? $agent->{'intervalo'} : $module->{'module_interval'}); + db_do ($dbh, 'UPDATE tagente_estado SET datos = ?, estado = ?, last_status = ?, status_changes = ?, utimestamp = ?, timestamp = ?, id_agente = ?, current_interval = ?, running_by = ?, last_execution_try = ?, last_try = ? WHERE id_agente_modulo = ?', $processed_data, $status, $last_status, $status_changes, diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index e9bc7891a1..3a185c88f3 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -456,7 +456,7 @@ sub process_module_data ($$$$$$$$$) { my $tags = {'name' => 0, 'data' => 0, 'type' => 0, 'description' => 0, 'max' => 0, 'min' => 0, 'descripcion' => 0, 'post_process' => 0, 'module_interval' => 0, 'min_critical' => 0, 'max_critical' => 0, 'min_warning' => 0, 'max_warning' => 0, 'disabled' => 0, 'min_ff_event' => 0, - 'datalist' => 0, 'status' => 0}; + 'datalist' => 0, 'status' => 0, 'timestamp' => 0}; # Other tags will be saved here $module_conf->{'extended_info'} = '';