$seeknum = 0;
    if (file_exists($seekfile)) {
        $seeknum = exec("cat {$seekfile}") + 0;
        echo "line num: {$seeknum}\n";
        parse_log($seekfile, $slogfile, $seeknum);
    } else {
        //建立当前日志seek文件,行数初始为0
        $fd = fopen($seekfile, 'w');
        fwrite($fd, "0");
        fclose($fd);
        //先跑晚昨天的日志
        $file = "S" . date("Ymd", strtotime("-1 day")) . ".log";
        $seekfile = $rcpath . "/var/" . $file . ".seek";
        $slogfile = $basepath . "/S" . date("Ymd", strtotime("-1 day")) . ".log";
        $seeknum = exec("cat {$seekfile}") + 0;
        parse_log($seekfile, $slogfile, $seeknum);
    }
    echo "sleep 5 sec.\n";
    sleep(2);
}
function parse_log($seekfile, $slogfile, $seeknum)
{
    $bufpath = "/data0/apache/gateway/print/INSERT/";
    $fd = fopen($slogfile, 'r');
    echo $file . "\n";
    if (!$fd) {
        trans_w_log('/data0/apache/gateway/withdb/logdb/mtlog2buf.log', "Content file open error!!!!\n");
        return;
    }
    $i = 0;
    $nowsec = time();
Ejemplo n.º 2
0
        return $service_cache["{$proto}"]["{$port}"];
    } else {
        return $port;
    }
}
/*
 * Begin Parameter parsing 
 */
if (trim($_GET['count'])) {
    $count = $_GET['count'];
} else {
    $count = '50';
}
$regexp = "'" . stripslashes($_GET['regexp']) . "'";
$pfhost = $_SESSION['pfhost']['connect'];
$logs = parse_log(`sudo {$inst_dir}/bin/commandwrapper.sh {$pfhost} -log -{$count} {$regexp} {$invert_match}`);
$stats = log_stats($logs);
if ($_SESSION['dns_cache']) {
    $dns_cache = $_SESSION['dns_cache'];
} else {
    $dns_cache = array();
}
if ($_SESSION['service_cache']) {
    $service_cache = $_SESSION['service_cache'];
} else {
    $service_cache = array();
}
/*
 * Begin Page Output
 */
page_header("filter", "..", $_GET['reload']);
    if (file_exists($seekfile)) {
        $seeknum = exec("cat {$seekfile}") + 0;
        echo "line num: {$seeknum}\n";
        parse_log($seekfile, $slogfile, $seeknum, $table);
    } else {
        //建立当前日志seek文件,行数初始为0
        $fd = fopen($seekfile, 'w');
        fwrite($fd, "0");
        fclose($fd);
        //先跑晚昨天的日志
        $file = "R" . date("Ymd", strtotime("-1 day")) . ".log";
        $seekfile = $rcpath . "/var/" . $file . ".seek";
        $slogfile = $basepath . "/R" . date("Ymd", strtotime("-1 day")) . ".log";
        $seeknum = exec("cat {$seekfile}") + 0;
        $table = "R" . date("Ymd", strtotime("-1 day"));
        parse_log($seekfile, $slogfile, $seeknum, $table);
    }
    echo "sleep 5 sec.\n";
    sleep(2);
}
function parse_log($seekfile, $slogfile, $seeknum, $tablename)
{
    global $Hcity;
    global $Hregion;
    $fd = fopen($slogfile, 'r');
    if (!$fd) {
        trans_w_log('/data0/apache/gateway/withdb/logdb3/insertDB_mo.log', "Content file open error!!!!\n");
        return;
    }
    $i = 0;
    $nowsec = time();
Ejemplo n.º 4
0
        exit;
    } else {
        if (file_exists($output)) {
            echo "ERROR: output file '{$output}' already exists\n";
            exit;
        }
    }
}
/* query timeout limit */
define('QUERY_TIMEOUT', 300);
echo "input directory: {$input}\n";
echo "output SQL file: {$output}\n\n";
// load the results from directory
$data = load_results($input);
// add information from the shell log
parse_log($data, "{$input}/bench.log");
// write the results into SQL
print_pgbench_sql($data, load_config("{$input}/pgbench.config"), $output);
print_tpch_sql($data, load_config("{$input}/tpch.config"), $output);
// build pgbench plots
build_pgbench_plots($input, 'images', $data);
/* FUNCTIONS */
/* loads results from the directories */
/* param $dir - directory with benchmark results */
function load_results($dir)
{
    $data = array();
    $fs_dir = opendir($dir);
    while ($fs = readdir($fs_dir)) {
        if (!is_dir("{$dir}/{$fs}") || in_array($fs, array('.', '..'))) {
            continue;
    // read log, parse and insert to db.
    if (file_exists($info_posfile)) {
        $cmd = $cat . ' ' . $info_posfile . ' 2>/dev/null';
        $pos = exec($cmd) + 0;
        parse_log($info_posfile, $pos, $info_log, $my_log);
    } else {
        //建立当前日志pos文件,行数初始为0
        $cmd = $echo . " '0' > {$info_posfile} 2>/dev/null";
        exec($cmd);
        //跑昨天的日志, 防止23:59分之后,且本进程被kill后,23:59分之后的log无法入库。
        $yesterday = date("Ymd", strtotime("-1 day"));
        $info_log = $log_path . '/' . $info_program . '.' . $yesterday . '.log';
        $info_posfile = $log_path . '/' . $info_program . '.' . $yesterday . '.pos';
        $cmd = $cat . ' ' . $info_posfile . ' 2>/dev/null';
        $pos = exec($cmd) + 0;
        parse_log($info_posfile, $pos, $info_log, $my_log);
    }
    sleep(2);
}
function sig_handler($signo)
{
    global $log_path;
    global $my_log;
    global $my_name;
    global $log_tag;
    global $my_tag;
    global $my_pidfile;
    global $pid;
    global $rm;
    global $pos;
    global $info_posfile;