From 55c25d883f9dd897b0e1a62e64fe7cbc3bb5a437 Mon Sep 17 00:00:00 2001 From: jsatoh Date: Sat, 31 May 2014 13:39:45 +0000 Subject: [PATCH] 2014-05-31 Junichi Satoh * lib/PandoraFMS/Core.pm: Improved 'FF threshold' to be able to define timeout. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10062 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index cca3c57718..667bdc7843 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2014-05-31 Junichi Satoh + + * lib/PandoraFMS/Core.pm: Improved 'FF threshold' to be able to define + timeout. + 2014-05-30 Sancho Lerena * conf/pandora_server.conf.new: Review of default configuration file. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 9994fb5b07..01444e72ea 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1063,6 +1063,7 @@ sub pandora_process_module ($$$$$$$$$;$) { my $last_data_value = $agent_status->{'datos'}; my $last_known_status = $agent_status->{'last_known_status'}; my $last_error = defined ($module->{'last_error'}) ? $module->{'last_error'} : $agent_status->{'last_error'}; + my $ff_start_utimestamp = $agent_status->{'ff_start_utimestamp'}; # Get new status my $new_status = get_module_status ($processed_data, $module, $module_type); @@ -1082,6 +1083,7 @@ sub pandora_process_module ($$$$$$$$$;$) { #Update module status my $min_ff_event = $module->{'min_ff_event'}; my $current_utimestamp = time (); + my $ff_timeout = $module->{'ff_timeout'}; if ($module->{'each_ff'}) { $min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0); @@ -1095,9 +1097,14 @@ sub pandora_process_module ($$$$$$$$$;$) { $status_changes = $min_ff_event if ($status_changes > $module->{'min_ff_event'}); $status_changes++; + if ($min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) { + $status_changes = 0; + $ff_start_utimestamp = $utimestamp; + } } else { $status_changes = 0; + $ff_start_utimestamp = $utimestamp; } # Active ff interval @@ -1148,10 +1155,11 @@ sub pandora_process_module ($$$$$$$$$;$) { SET datos = ?, estado = ?, last_status = ?, last_known_status = ?, status_changes = ?, utimestamp = ?, timestamp = ?, id_agente = ?, current_interval = ?, running_by = ?, - last_execution_try = ?, last_try = ?, last_error = ? + last_execution_try = ?, last_try = ?, last_error = ?, + ff_start_utimestamp = ? WHERE id_agente_modulo = ?', $processed_data, $status, $last_status, $last_status, $status_changes, $current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id, - $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $module->{'id_agente_modulo'}); + $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp, $module->{'id_agente_modulo'}); # Save module data. Async and log4x modules are not compressed. if ($module_type =~ m/(async)|(log4x)/ || $save == 1) {