diff --git a/www/class/centreonPurgeEngine.class.php b/www/class/centreonPurgeEngine.class.php index 3cfaecc5f339ad218cbf60f35fd72618da750ffb..7ba1b40ecc16e5bc2aedb4e5302c0827fe134b0e 100644 --- a/www/class/centreonPurgeEngine.class.php +++ b/www/class/centreonPurgeEngine.class.php @@ -45,46 +45,11 @@ require_once(realpath(dirname(__FILE__) . "/centreonDB.class.php")); class CentreonPurgeEngine { private $dbCentstorage; - private $tablesToPurge = array( - 'data_bin' => array( - 'retention_field' => 'len_storage_mysql', - 'retention' => 0, - 'is_partitioned' => false, - 'ctime_field' => 'ctime' - ), - 'logs' => array( - 'retention_field' => 'archive_retention', - 'retention' => 0, - 'is_partitioned' => false, - 'ctime_field' => 'ctime' - ), - 'log_archive_host' => array( - 'retention_field' => 'reporting_retention', - 'retention' => 0, - 'is_partitioned' => false, - 'ctime_field' => 'date_end' - ), - 'log_archive_service' => array( - 'retention_field' => 'reporting_retention', - 'retention' => 0, - 'is_partitioned' => false, - 'ctime_field' => 'date_end' - ), - 'comments' => array( - 'retention_field' => 'len_storage_comments', - 'retention' => 0, - 'is_partitioned' => false, - 'custom_query' => 'DELETE FROM comments WHERE (deletion_time is not null and deletion_time ' . - '< __RETENTION__) OR (expire_time < __RETENTION__ AND expire_time <> 0)' - ), - 'downtimes' => array( - 'retention_field' => 'len_storage_downtimes', - 'retention' => 0, - 'is_partitioned' => false, - 'custom_query' => 'DELETE FROM downtimes WHERE (actual_end_time is not null and actual_end_time ' . - '< __RETENTION__) OR (deletion_time is not null and deletion_time < __RETENTION__)' - ), - ); + + private $purgeCommentsQuery; + private $purgeDowntimesQuery; + + private $tablesToPurge; /** * @@ -92,6 +57,50 @@ class CentreonPurgeEngine */ public function __construct() { + $this->purgeCommentsQuery = 'DELETE FROM comments WHERE (deletion_time is not null and deletion_time ' . + '< __RETENTION__) OR (expire_time < __RETENTION__ AND expire_time <> 0)'; + $this->purgeDowntimesQuery = 'DELETE FROM downtimes WHERE (actual_end_time is not null and actual_end_time ' . + '< __RETENTION__) OR (deletion_time is not null and deletion_time < __RETENTION__)'; + + $this->tablesToPurge = array( + 'data_bin' => array( + 'retention_field' => 'len_storage_mysql', + 'retention' => 0, + 'is_partitioned' => false, + 'ctime_field' => 'ctime' + ), + 'logs' => array( + 'retention_field' => 'archive_retention', + 'retention' => 0, + 'is_partitioned' => false, + 'ctime_field' => 'ctime' + ), + 'log_archive_host' => array( + 'retention_field' => 'reporting_retention', + 'retention' => 0, + 'is_partitioned' => false, + 'ctime_field' => 'date_end' + ), + 'log_archive_service' => array( + 'retention_field' => 'reporting_retention', + 'retention' => 0, + 'is_partitioned' => false, + 'ctime_field' => 'date_end' + ), + 'comments' => array( + 'retention_field' => 'len_storage_comments', + 'retention' => 0, + 'is_partitioned' => false, + 'custom_query' => $this->purgeCommentsQuery + ), + 'downtimes' => array( + 'retention_field' => 'len_storage_downtimes', + 'retention' => 0, + 'is_partitioned' => false, + 'custom_query' => $this->purgeDowntimesQuery + ), + ); + $this->dbCentstorage = new \CentreonDB('centstorage'); $this->readConfig();