コード例 #1
0
ファイル: hook_cron.php プロジェクト: SysBind/simplesamlphp
/**
 * Hook to run a cron job.
 *
 * @param array &$croninfo  Output
 */
function statistics_hook_cron(&$croninfo)
{
    assert('is_array($croninfo)');
    assert('array_key_exists("summary", $croninfo)');
    assert('array_key_exists("tag", $croninfo)');
    $statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
    if (is_null($statconfig->getValue('cron_tag', NULL))) {
        return;
    }
    if ($statconfig->getValue('cron_tag', NULL) !== $croninfo['tag']) {
        return;
    }
    $maxtime = $statconfig->getInteger('time_limit', NULL);
    if ($maxtime) {
        set_time_limit($maxtime);
    }
    try {
        $aggregator = new sspmod_statistics_Aggregator();
        $results = $aggregator->aggregate();
        if (empty($results)) {
            SimpleSAML\Logger::notice('Output from statistics aggregator was empty.');
        } else {
            $aggregator->store($results);
        }
    } catch (Exception $e) {
        $message = 'Loganalyzer threw exception: ' . $e->getMessage();
        SimpleSAML\Logger::warning($message);
        $croninfo['summary'][] = $message;
    }
}
コード例 #2
0
        case '--dry-run':
            $dryrun = TRUE;
            break;
        default:
            echo 'Unknown option: ' . $a . "\n";
            echo 'Please run `' . $progName . ' --help` for usage information.' . "\n";
            exit(1);
    }
}
$aggregator = new sspmod_statistics_Aggregator(TRUE);
$aggregator->dumpConfig();
$aggregator->debugInfo();
$results = $aggregator->aggregate($debug);
$aggregator->debugInfo();
if (!$dryrun) {
    $aggregator->store($results);
}
foreach ($results as $slot => $val) {
    foreach ($val as $sp => $no) {
        echo $sp . " " . count($no) . " - ";
    }
    echo "\n";
}
/**
 * This function prints the help output.
 */
function printHelp()
{
    global $progName;
    /*   '======================================================================' */
    echo 'Usage: ' . $progName . ' [options]