From 4081e8301bbac468c59eedbbb9951f8b2174436b Mon Sep 17 00:00:00 2001 From: slerena Date: Thu, 21 Aug 2008 19:03:19 +0000 Subject: [PATCH] 2008-08-21 Sancho Lerena * lib/PandoraFMS/DB.pm, bin/pandora_server: Enabled again downtime scheduler. Now works fine, tested. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1018 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/bin/pandora_server | 2 +- pandora_server/lib/PandoraFMS/DB.pm | 11 ++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 1b24747a15..8f3b4fcc90 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2008-08-21 Sancho Lerena + + * lib/PandoraFMS/DB.pm, bin/pandora_server: Enabled again + downtime scheduler. Now works fine, tested. + 2008-08-07 Sancho Lerena * bin/pandora_server: Disabled downtime server code until diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 2a5c6e6e9d..ea13f44419 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -94,7 +94,7 @@ my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost:3306", while (1) { pandora_serverkeepaliver (\%pa_config, 0, $dbh); # Disabled until we can finish code from editor and update server code - # pandora_planned_downtime (\%pa_config, $dbh); + pandora_planned_downtime (\%pa_config, $dbh); keep_alive_check (\%pa_config, $dbh); threads->yield; sleep ($pa_config{"server_threshold"}); diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index c231ee05db..ad087bcbd4 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -1329,13 +1329,14 @@ sub pandora_planned_downtime (%$) { my $query_handle; my $query_handle2; my $query_sql; - my $datestamp = &UnixDate("today","%Y-%m-%d"); - my $timestamp = &UnixDate("today","%H:%M:%S"); - + + my $timestamp = &UnixDate("today","%Y-%m-%d %H:%M:%S"); + my $utimestamp; # integer version of timestamp + $utimestamp = &UnixDate($timestamp,"%s"); # convert from # Activate a planned downtime: Set agents as disabled for Planned Downtime - $query_sql = "SELECT * FROM tplanned_downtime WHERE executed = 0 AND start <= '$datestamp' AND start_time <= '$timestamp' AND stop >= '$datestamp' AND stop_time >'$timestamp' "; + $query_sql = "SELECT * FROM tplanned_downtime WHERE executed = 0 AND date_from <= $utimestamp AND date_to >= $utimestamp"; $query_handle = $dbh->prepare($query_sql); $query_handle ->execute; @@ -1359,7 +1360,7 @@ sub pandora_planned_downtime (%$) { # Deactivate a planned downtime: Set agents as disabled for Planned Downtime - $query_sql = "SELECT * FROM tplanned_downtime WHERE executed = 1 AND stop <= '$datestamp' AND stop_time <= '$timestamp'"; + $query_sql = "SELECT * FROM tplanned_downtime WHERE executed = 1 AND date_to <= $utimestamp"; $query_handle = $dbh->prepare($query_sql); $query_handle ->execute; if ($query_handle->rows != 0) {