zmstats.pl: add use warnings. Fix log deletion only ever deleting 100 when it should delete more in a loop. Add deleting more than 100 sessions. Fix loop not terminating on Ctrl-C
This commit is contained in:
parent
9f6eec792c
commit
be5c6371bb
|
@ -1,5 +1,6 @@
|
|||
#!@PERL_EXECUTABLE@ -wT
|
||||
use strict;
|
||||
use warnings;
|
||||
use bytes;
|
||||
|
||||
# ==========================================================================
|
||||
|
@ -79,14 +80,18 @@ while (!$zm_terminate) {
|
|||
}
|
||||
my $rows;
|
||||
do {
|
||||
my $rows = zmDbDo('DELETE FROM `Logs` WHERE `TimeKey` < unix_timestamp(now() - interval '.$Config{ZM_LOG_DATABASE_LIMIT}.') LIMIT 100');
|
||||
Debug("Deleted $rows log table entries by time") if defined $rows;
|
||||
} while ($rows);
|
||||
$rows = zmDbDo('DELETE FROM `Logs` WHERE `TimeKey` < unix_timestamp(now() - interval '.$Config{ZM_LOG_DATABASE_LIMIT}.') LIMIT 100');
|
||||
Debug("Deleted $rows log table entries by time") if $rows;
|
||||
} while ($rows and ($rows == 100) and !$zm_terminate);
|
||||
}
|
||||
} # end if ZM_LOG_DATABASE_LIMIT
|
||||
|
||||
# Delete any sessions that are more ethan a week old. Limiting to 100 because mysql sucks
|
||||
zmDbDo('DELETE FROM Sessions WHERE access < ? LIMIT 100', time - (60*60*24*7));
|
||||
my $rows;
|
||||
do {
|
||||
# Delete any sessions that are more than a week old. Limiting to 100 because mysql sucks
|
||||
$rows = zmDbDo('DELETE FROM Sessions WHERE access < ? LIMIT 100', time - (60*60*24*7));
|
||||
Debug("Deleted $rows sessions") if $rows;
|
||||
} while ($rows and ($rows == 100) and !$zm_terminate);
|
||||
|
||||
sleep($Config{ZM_STATS_UPDATE_INTERVAL});
|
||||
} # end while (!$zm_terminate)
|
||||
|
|
Loading…
Reference in New Issue