summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/statistics/hooks/cron.inc.php17
-rw-r--r--modules-available/syslog/hooks/cron.inc.php5
2 files changed, 18 insertions, 4 deletions
diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php
index 94c65248..575ab6ba 100644
--- a/modules-available/statistics/hooks/cron.inc.php
+++ b/modules-available/statistics/hooks/cron.inc.php
@@ -1,8 +1,5 @@
<?php
-Database::exec("DELETE FROM statistic WHERE (UNIX_TIMESTAMP() - dateline) > 86400 * 190");
-Database::exec("DELETE FROM machine WHERE (UNIX_TIMESTAMP() - lastseen) > 86400 * 365");
-
function logstats() {
$NOW = time();
$cutoff = $NOW - 86400 * 30;
@@ -15,4 +12,18 @@ function logstats() {
'vals' => $known['val'] . '#' . $on['val'] . '#' . $used['val'],
));
}
+
logstats();
+
+if (mt_rand(1, 10) === 1) {
+ Database::exec("DELETE FROM statistic WHERE (UNIX_TIMESTAMP() - 86400 * 190) > dateline");
+ if (mt_rand(1, 100) === 1) {
+ Database::exec("OPTIMIZE TABLE statistic");
+ }
+}
+if (mt_rand(1, 10) === 1) {
+ Database::exec("DELETE FROM machine WHERE (UNIX_TIMESTAMP() - 86400 * 365) > lastseen");
+ if (mt_rand(1, 100) === 1) {
+ Database::exec("OPTIMIZE TABLE machine");
+ }
+}
diff --git a/modules-available/syslog/hooks/cron.inc.php b/modules-available/syslog/hooks/cron.inc.php
index c796675f..bae882a9 100644
--- a/modules-available/syslog/hooks/cron.inc.php
+++ b/modules-available/syslog/hooks/cron.inc.php
@@ -1,5 +1,8 @@
<?php
if (mt_rand(1, 10) === 1) {
- Database::exec("DELETE FROM clientlog WHERE (UNIX_TIMESTAMP() - dateline) > 86400 * 190");
+ Database::exec("DELETE FROM clientlog WHERE (UNIX_TIMESTAMP() - 86400 * 190) > dateline");
+ if (mt_rand(1, 100) === 1) {
+ Database::exec("OPTIMIZE TABLE clientlog");
+ }
} \ No newline at end of file