From 93bd4b86a050569c757e3065483343c340cdb1be Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Mon, 6 Jun 2011 16:33:32 +0000
Subject: [PATCH] 2011-06-06  Ramon Novoa  <rnovoa@artica.es>

	* util/pandora_db.pl: Use days_compact instead of days_purge in
	  pandora_compactdb.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4412 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog          | 5 +++++
 pandora_server/util/pandora_db.pl | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 32470a424f..e922b1300e 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-06  Ramon Novoa  <rnovoa@artica.es>
+
+	* util/pandora_db.pl: Use days_compact instead of days_purge in
+	  pandora_compactdb.
+
 2011-06-03  SanchO Lerena <slerena@artica.es>
 
 	* pandora_inventory_change.pl
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 53b6e7b93e..355601a230 100755
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -30,7 +30,7 @@ use PandoraFMS::Tools;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "3.1 PS100310";
+my $version = "4.0 PS100310";
 
 # Pandora server configuration
 my %conf;
@@ -266,7 +266,7 @@ sub pandora_compactdb ($$) {
 	my %id_agent_hash;
 	my %value_hash;
 
-	return if ($conf->{'_days_purge'} == 0 || $conf->{'_step_compact'} < 1);
+	return if ($conf->{'_days_compact'} == 0 || $conf->{'_step_compact'} < 1);
 
 	# Compact interval length in seconds
 	# $conf->{'_step_compact'} varies between 1 (36 samples/day) and
@@ -278,7 +278,7 @@ sub pandora_compactdb ($$) {
 	return unless (defined ($limit_utime) && $limit_utime > 0);
 
 	# Calculate the start date
-	my $start_utime = time() - $conf->{'_days_purge'} * 24 * 60 * 60;
+	my $start_utime = time() - $conf->{'_days_compact'} * 24 * 60 * 60;
 	my $stop_utime;
 
 	print "[COMPACT] Compacting data until " . strftime ("%Y-%m-%d %H:%M:%S", localtime($start_utime)) ."\n";
@@ -392,7 +392,6 @@ sub pandora_load_config ($) {
 	$conf->{'_days_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_purge'");
 	$conf->{'_days_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_compact'");
 	$conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'");
-	$conf->{'_step_compact'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'step_compact'");
 	$conf->{'_history_db_enabled'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_enabled'");
 	$conf->{'_history_db_host'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_host'");
 	$conf->{'_history_db_port'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_port'");