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

Support input file parameter to logcleaner

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1393 44740490-163a-0410-bde0-09ae8108e29a
parent bc353dd0
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ $progName = array_shift($argv); ...@@ -17,6 +17,7 @@ $progName = array_shift($argv);
$debug = FALSE; $debug = FALSE;
$dryrun = FALSE; $dryrun = FALSE;
$output = '/tmp/simplesamlphp-new.log'; $output = '/tmp/simplesamlphp-new.log';
$infile = NULL;
foreach($argv as $a) { foreach($argv as $a) {
if(strlen($a) === 0) continue; if(strlen($a) === 0) continue;
...@@ -45,6 +46,9 @@ foreach($argv as $a) { ...@@ -45,6 +46,9 @@ foreach($argv as $a) {
case '--dry-run': case '--dry-run':
$dryrun = TRUE; $dryrun = TRUE;
break; break;
case '--infile':
$infile = $v;
break;
case '--outfile': case '--outfile':
$output = $v; $output = $v;
break; break;
...@@ -55,7 +59,7 @@ foreach($argv as $a) { ...@@ -55,7 +59,7 @@ foreach($argv as $a) {
} }
} }
$cleaner = new sspmod_statistics_LogCleaner(); $cleaner = new sspmod_statistics_LogCleaner($infile);
$cleaner->dumpConfig(); $cleaner->dumpConfig();
$todelete = $cleaner->clean($debug); $todelete = $cleaner->clean($debug);
...@@ -80,6 +84,7 @@ The script deletes log lines related to sessions that produce more than 200 line ...@@ -80,6 +84,7 @@ The script deletes log lines related to sessions that produce more than 200 line
Options: Options:
-d, --debug Used when configuring the log file syntax. See doc. -d, --debug Used when configuring the log file syntax. See doc.
--dry-run Aggregate but do not store the results. --dry-run Aggregate but do not store the results.
--infile File input.
--outfile File to output the results. --outfile File to output the results.
'); ');
......
...@@ -15,7 +15,7 @@ class sspmod_statistics_LogCleaner { ...@@ -15,7 +15,7 @@ class sspmod_statistics_LogCleaner {
/** /**
* Constructor * Constructor
*/ */
public function __construct() { public function __construct($inputfile = NULL) {
$this->statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php'); $this->statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
...@@ -23,6 +23,8 @@ class sspmod_statistics_LogCleaner { ...@@ -23,6 +23,8 @@ class sspmod_statistics_LogCleaner {
$this->inputfile = $this->statconfig->getValue('inputfile'); $this->inputfile = $this->statconfig->getValue('inputfile');
$this->statrules = $this->statconfig->getValue('statrules'); $this->statrules = $this->statconfig->getValue('statrules');
$this->offset = $this->statconfig->getValue('offset', 0); $this->offset = $this->statconfig->getValue('offset', 0);
if (isset($inputfile)) $this->inputfile = $inputfile;
} }
public function dumpConfig() { public function dumpConfig() {
......
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