Skip to content
Snippets Groups Projects
Commit fe801a33 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

statistics: aggregator trims cols and more effective reading of large files...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1387 44740490-163a-0410-bde0-09ae8108e29a
parent c1b0274f
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ class sspmod_statistics_Aggregator { ...@@ -45,7 +45,7 @@ class sspmod_statistics_Aggregator {
$file = fopen($this->inputfile, 'r'); $file = fopen($this->inputfile, 'r');
$logfile = file($this->inputfile, FILE_IGNORE_NEW_LINES ); #$logfile = file($this->inputfile, FILE_IGNORE_NEW_LINES );
$logparser = new sspmod_statistics_LogParser( $logparser = new sspmod_statistics_LogParser(
...@@ -57,8 +57,10 @@ class sspmod_statistics_Aggregator { ...@@ -57,8 +57,10 @@ class sspmod_statistics_Aggregator {
$i = 0; $i = 0;
// Parse through log file, line by line // Parse through log file, line by line
foreach ($logfile AS $logline) { while (!feof($file)) {
$logline = fgets($file, 4096);
// Continue if STAT is not found on line. // Continue if STAT is not found on line.
if (!preg_match('/STAT/', $logline)) continue; if (!preg_match('/STAT/', $logline)) continue;
$i++; $i++;
...@@ -66,9 +68,16 @@ class sspmod_statistics_Aggregator { ...@@ -66,9 +68,16 @@ class sspmod_statistics_Aggregator {
// Parse log, and extract epoch time and rest of content. // Parse log, and extract epoch time and rest of content.
$epoch = $logparser->parseEpoch($logline); $epoch = $logparser->parseEpoch($logline);
$content = $logparser->parseContent($logline); $content = $logparser->parseContent($logline);
$action = $content[5]; $action = trim($content[5]);
if (($i % 10000) == 0) {
echo("Read line " . $i . "\n");
}
if ($debug) { if ($debug) {
echo("----------------------------------------\n"); echo("----------------------------------------\n");
echo('Log line: ' . $logline . "\n"); echo('Log line: ' . $logline . "\n");
echo('Date parse [' . substr($logline, 0, $this->statconfig->getValue('datelength', 15)) . '] to [' . date(DATE_RFC822, $epoch) . ']' . "\n"); echo('Date parse [' . substr($logline, 0, $this->statconfig->getValue('datelength', 15)) . '] to [' . date(DATE_RFC822, $epoch) . ']' . "\n");
...@@ -88,7 +97,7 @@ class sspmod_statistics_Aggregator { ...@@ -88,7 +97,7 @@ class sspmod_statistics_Aggregator {
if (isset($rule['action']) && ($action !== $rule['action'])) continue; if (isset($rule['action']) && ($action !== $rule['action'])) continue;
$difcol = $content[$rule['col']]; // echo '[...' . $difcol . '...]'; $difcol = trim($content[$rule['col']]); // echo '[...' . $difcol . '...]';
if (!isset($results[$rulename][$fileslot][$timeslot]['_'])) $results[$rulename][$fileslot][$timeslot]['_'] = 0; if (!isset($results[$rulename][$fileslot][$timeslot]['_'])) $results[$rulename][$fileslot][$timeslot]['_'] = 0;
if (!isset($results[$rulename][$fileslot][$timeslot][$difcol])) $results[$rulename][$fileslot][$timeslot][$difcol] = 0; if (!isset($results[$rulename][$fileslot][$timeslot][$difcol])) $results[$rulename][$fileslot][$timeslot][$difcol] = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment