From c8273efad41170498abdf800da801da4f96e8c53 Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 23 Dec 2009 12:51:12 +0000 Subject: [PATCH] 2009-12-23 Sancho Lerena * lib/PandoraFMS/Core.pm: Fixed some typos in planned downtime subroutine. * bin/pandora_server: Some operations like planned downtime check and server down detection are put in a low-priority check, more efficient and less time-consuming. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2235 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 8 ++++++++ pandora_server/bin/pandora_server | 20 ++++++++++++++------ pandora_server/lib/PandoraFMS/Core.pm | 11 ++++++----- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index aad5027a3c..48625c752a 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2009-12-23 Sancho Lerena + + * lib/PandoraFMS/Core.pm: Fixed some typos in planned downtime subroutine. + + * bin/pandora_server: Some operations like planned downtime check and + server down detection are put in a low-priority check, more efficient and + less time-consuming. + 2009-12-21 Ramon Novoa * lib/PandoraFMS/Core.pm: Fixed agent check in logger call. diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 5953d9ddd6..83e16156c6 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -164,7 +164,7 @@ foreach my $server (@Servers) { # Main loop my $time_ref = time (); -my $mcast_timer = 0; +my $task_timer = 0; while (1) { @@ -179,16 +179,24 @@ while (1) { # Update fallen servers db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); - pandora_planned_downtime (\%Config, $DBH); pandora_exec_forced_alerts (\%Config, $DBH); + pandora_module_keep_alive_nd (\%Config, $DBH); - # Multicast status report each 30 x Server Threshold secs - if ($mcast_timer > 30){ + # Tasks executed only each Server Threshold x 30 secs, for low-priority tasks + + if ($task_timer > 30){ + # Multicast status report each 30 x Server Threshold secs enterprise_hook('mcast_status_report', [\%Config, $DBH]); - $mcast_timer = 0; + $task_timer = 0; + + # Downtimes are executed only 30 x Server Threshold secs + pandora_planned_downtime (\%Config, $DBH); + + # Update fallen servers + db_do ($DBH, "UPDATE tserver SET status = 0 WHERE keepalive < ?", strftime ("%Y-%m-%d %H:%M:%S", localtime(time() - $Config{'keepalive'}))); } - $mcast_timer++; + $task_timer++; }; # Restart on error or auto restart diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index b6f252d09b..501004a48c 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -626,15 +626,15 @@ sub pandora_planned_downtime ($$) { foreach my $downtime (@downtimes) { - logger($pa_config, "Starting planned downtime '" . $downtime->{'nombre'} . "'.", 10); + logger($pa_config, "Starting planned downtime '" . $downtime->{'name'} . "'.", 10); db_do($dbh, 'UPDATE tplanned_downtime SET executed = 1 WHERE id = ?', $downtime->{'id'}); pandora_event ($pa_config, "Server ".$pa_config->{'servername'}." started planned downtime: ".$downtime->{'description'}, 0, 0, 1, 0, 0, 'system', $dbh); - my @downtime_agents = db_do($dbh, 'SELECT * FROM tplanned_downtime_agents WHERE id_downtime = ' . $downtime->{'id'}); + my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents WHERE id_downtime = ' . $downtime->{'id'}); foreach my $downtime_agent (@downtime_agents) { - db_do ($dbh, 'UPDATE tagente SET disabled = 1 WHERE id_grupo = ?', $downtime_agent->{'id_group'}); + db_do ($dbh, 'UPDATE tagente SET disabled = 1 WHERE id_agente = ?', $downtime_agent->{'id_agent'}); } } @@ -642,15 +642,16 @@ sub pandora_planned_downtime ($$) { @downtimes = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime WHERE executed = 1 AND date_to <= ?', $utimestamp); foreach my $downtime (@downtimes) { - logger($pa_config, "Ending planned downtime '" . $downtime->{'nombre'} . "'.", 10); + logger($pa_config, "Ending planned downtime '" . $downtime->{'name'} . "'.", 10); db_do($dbh, 'UPDATE tplanned_downtime SET executed = 0 WHERE id = ?', $downtime->{'id'}); + pandora_event ($pa_config, 'Server ' . $pa_config->{'servername'} . ' stopped planned downtime: ' . $downtime->{'description'}, 0, 0, 1, 0, 0, 'system', $dbh); my @downtime_agents = get_db_rows($dbh, 'SELECT * FROM tplanned_downtime_agents WHERE id_downtime = ' . $downtime->{'id'}); foreach my $downtime_agent (@downtime_agents) { - db_do ($dbh, 'UPDATE tagente SET disabled = 0 WHERE id_agrupo = ?', $downtime_agent->{'id_group'}); + db_do ($dbh, 'UPDATE tagente SET disabled = 0 WHERE id_agente = ?', $downtime_agent->{'id_agent'}); } } }