Commit e7d69dff authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Keep last 24 hours of data on ops, as a sliding window, pushed every

hour from crontab.
parent e8efc047
...@@ -148,6 +148,12 @@ if (!defined($lastidx)) { ...@@ -148,6 +148,12 @@ if (!defined($lastidx)) {
unlink("${tempfile}.pair_data") unlink("${tempfile}.pair_data")
if (-e "${tempfile}.pair_data"); if (-e "${tempfile}.pair_data");
#
# Compute the cutoff age; We leave MAXAGE old entries here, and ship
# the rest over to the DP.
#
my $cutoffage = (time() - $MAXAGE) * 1.0;
# #
# Must lock the table of course # Must lock the table of course
# #
...@@ -157,7 +163,7 @@ DBQueryFatal("lock tables pair_data write"); ...@@ -157,7 +163,7 @@ DBQueryFatal("lock tables pair_data write");
# Grab all of the new entries and store to the file # Grab all of the new entries and store to the file
# #
DBQueryFatal("select * from pair_data ". DBQueryFatal("select * from pair_data ".
"where idx > $lastidx " . "where idx > $lastidx and unixstamp < $cutoffage ".
"into outfile '${tempfile}.pair_data' ". "into outfile '${tempfile}.pair_data' ".
"fields terminated by ' '"); "fields terminated by ' '");
...@@ -166,7 +172,7 @@ DBQueryFatal("select * from pair_data ". ...@@ -166,7 +172,7 @@ DBQueryFatal("select * from pair_data ".
# #
$query_result = $query_result =
DBQueryFatal("select idx from pair_data ". DBQueryFatal("select idx from pair_data ".
"where idx > $lastidx " . "where idx > $lastidx and unixstamp < $cutoffage " .
"order by idx desc limit 1"); "order by idx desc limit 1");
# Save for later. # Save for later.
$lastidx = $query_result->fetchrow_array(); $lastidx = $query_result->fetchrow_array();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment