ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
loganalyzer.php
Go to the documentation of this file.
1 #!/usr/bin/env php
2 <?php
3 
4 // This is the base directory of the SimpleSAMLphp installation
5 $baseDir = dirname(dirname(dirname(dirname(__FILE__))));
6 
7 // Add library autoloader.
8 require_once($baseDir . '/lib/_autoload.php');
9 
10 // Initialize the configuration.
11 $configdir = SimpleSAML\Utils\Config::getConfigDir();
14 
15 $progName = array_shift($argv);
16 $debug = false;
17 $dryrun = false;
18 
19 foreach($argv as $a) {
20  if (strlen($a) === 0) {
21  continue;
22  }
23  if (strpos($a, '=') !== false) {
24  $p = strpos($a, '=');
25  $v = substr($a, $p + 1);
26  $a = substr($a, 0, $p);
27  } else {
28  $v = null;
29  }
30 
31  // Map short options to long options.
32  $shortOptMap = array('-d' => '--debug');
33  if (array_key_exists($a, $shortOptMap)) {
34  $a = $shortOptMap[$a];
35  }
36  switch ($a) {
37  case '--help':
38  printHelp();
39  exit(0);
40  case '--debug':
41  $debug = true;
42  break;
43  case '--dry-run':
44  $dryrun = true;
45  break;
46  default:
47  echo('Unknown option: ' . $a . "\n");
48  echo('Please run `' . $progName . ' --help` for usage information.' . "\n");
49  exit(1);
50  }
51 }
52 
54 $aggregator->dumpConfig();
55 $aggregator->debugInfo();
56 $results = $aggregator->aggregate($debug);
57 $aggregator->debugInfo();
58 
59 if (!$dryrun) {
60  $aggregator->store($results);
61 }
62 
63 foreach ($results AS $slot => $val) {
64  foreach ($val AS $sp => $no) {
65  echo $sp . " " . count($no) . " - ";
66  }
67  echo "\n";
68 }
69 
70 
75 function printHelp() {
76  global $progName;
77 
78  echo <<<END
79 Usage: $progName [options]
80 
81 This program parses and aggregates SimpleSAMLphp log files.
82 
83 Options:
84  -d, --debug Used when configuring the log file syntax. See doc.
85  --dry-run Aggregate but do not store the results.
86 END;
87 
88 }
89 
global $argv
Definition: svg-scanner.php:41
$baseDir
Definition: loganalyzer.php:5
foreach($argv as $a) $aggregator
Definition: loganalyzer.php:53
$progName
Definition: loganalyzer.php:15
if(! $dryrun) foreach($results AS $slot=> $val) printHelp()
This function prints the help output.
Definition: loganalyzer.php:75
static initTimezone()
Initialize the timezone.
Definition: Time.php:52
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.
Reload workbook from saved file
$dryrun
Definition: loganalyzer.php:17
Create styles array
The data for the language used.
$debug
Definition: loganalyzer.php:16
Done writing files
$configdir
Definition: loganalyzer.php:11
Temporary autoloader to ensure compatibility with old, non-PSR-2 compliant classes.
$results
Definition: loganalyzer.php:56