コード例 #1
0
<?php

error_reporting(E_ALL | E_STRICT);
require '../lib/cli.php';
require '../lib/factory.php';
F::init();
F::$dbo->setProfiling(false);
$fields = array('conn' => array('processed' => 0, 'fields' => cli::CAT_FIELDS_CONN), 'rule' => array('processed' => 0, 'fields' => cli::CAT_FIELDS_RULE));
$_l = new nCurse(0, 40, 0, 0);
$_l->reset('Process status');
$_l->refresh();
$_r = new nCurse(0, 0, 0, 40);
$_r->reset('Process log');
$_r->refresh();
$totals = F::$dbo->fetch('SELECT cat_name, count(id) AS cnt FROM raw_log WHERE cat_name IN ("' . strtoupper(implode('","', array_keys($fields))) . '") GROUP BY cat_name');
foreach ($totals as $tRow) {
    $_l->sprintf(' %s: 0 of %s', $tRow['cat_name'], number_format($tRow['cnt'], 0));
}
$_l->refresh();
foreach ($fields as $cat => $info) {
    $_r->println('Truncate table `cat_' . $cat . '`');
    $_r->refresh();
    F::$dbo->query('TRUNCATE `cat_' . $cat . '`');
    $_r->println('   Collecting RAW data');
    $_r->refresh();
    $q = F::$dbo->query('SELECT id, remote_ip, datetime, data FROM raw_log WHERE cat_name = "' . strtoupper($cat) . '" ORDER BY id ASC');
    $_r->println('   Processing');
    $_r->refresh();
    foreach ($q as $row) {
        $msgRaw = array();
        foreach (explode("\n", $row['data']) as $value) {
コード例 #2
0
ファイル: udp.php プロジェクト: EsterniTY/dfl860e-logger
        }
        if (count($gcTimings) > 0) {
            $_wLeft->println(str_pad('=[GC Timings]', 23, '='));
            foreach ($gcTimings as $tbl => $info) {
                $_wLeft->println('  ' . $tbl . ': ' . $info);
            }
        }
        $mem = number_format(memory_get_usage(), 0, '.', ',');
        $peak = number_format(memory_get_peak_usage(), 0, '.', ',');
        $peakR = number_format(memory_get_peak_usage(true), 0, '.', ',');
        $_wLeft->println(str_pad('=[Stats]', 23, '='));
        $_wLeft->println('  Mem: ' . $mem . ' bytes');
        $_wLeft->println('  Peak: ' . $peak . ' bytes');
        $_wLeft->println('  Real: ' . $peakR . ' bytes');
        $_wLeft->refresh();
        $_wRight->refresh();
        foreach ($gc as $cat => $time) {
            if ($gc[$cat] + cli::GARBAGE_COLLECTING_INTERVAL <= $curTime) {
                F::$dbo->resetTimer();
                $gc[$cat] = cli::cleanGarbage($cat, $curTime);
                $gcTimings[$cat] = F::$dbo->getTimer();
                break;
            }
        }
        gc_collect_cycles();
        if ($key == NCURSES_KEY_F10) {
            break;
        }
    }
    // while
} catch (Exception $e) {