ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.
8require_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
19foreach($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();
57$aggregator->debugInfo();
58
59if (!$dryrun) {
60 $aggregator->store($results);
61}
62
63foreach ($results AS $slot => $val) {
64 foreach ($val AS $sp => $no) {
65 echo $sp . " " . count($no) . " - ";
66 }
67 echo "\n";
68}
69
70
75function printHelp() {
76 global $progName;
77
78 echo <<<END
79Usage: $progName [options]
80
81This program parses and aggregates SimpleSAMLphp log files.
82
83Options:
84 -d, --debug Used when configuring the log file syntax. See doc.
85 --dry-run Aggregate but do not store the results.
86END;
87
88}
89
exit
Definition: backend.php:16
An exception for terminatinating execution or to throw for unit testing.
static initTimezone()
Initialize the timezone.
Definition: Time.php:51
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.
$results
Definition: loganalyzer.php:56
$progName
Definition: loganalyzer.php:15
foreach($argv as $a) $aggregator
Definition: loganalyzer.php:53
$debug
Definition: loganalyzer.php:16
$baseDir
Definition: loganalyzer.php:5
if(! $dryrun) foreach( $results AS $slot=> $val) printHelp()
This function prints the help output.
Definition: loganalyzer.php:75
$configdir
Definition: loganalyzer.php:11
$dryrun
Definition: loganalyzer.php:17
run()
Runs the loop.
Definition: functions.php:130
Temporary autoloader to ensure compatibility with old, non-PSR-2 compliant classes.
global $argv
Definition: svg-scanner.php:41