示例#1
0
function main($server_cfg)
{
    $eu_conf = parse_ini_file($server_cfg['eu_conf_file'], true);
    $db_host = $eu_conf['DB']['host'];
    $db_user = $eu_conf['DB']['user'];
    $db_pwd = $eu_conf['DB']['password'];
    $log_file = sprintf($server_cfg['log_file'], "add_correct_p_tag");
    log_msg("Starting [partition_dynamics]", $log_file);
    log_msg("db_host: {$db_host}", $log_file);
    $con = mysql_connect($db_host, $db_user, $db_pwd);
    $con or die("mysql_connect failed: " . mysql_error());
    $query = "select table_schema from information_schema.tables where\n                        table_name = 'xhprof_blob_30min'";
    $res_a = mysql_query_p($query, $con, $log_file);
    $db_array = array();
    while ($row_a = mysql_fetch_assoc($res_a)) {
        $db_array[] = $row_a['table_schema'];
    }
    add_correct_p_tag($db_array, $con, $log_file);
    mysql_close($con);
}
function report_partitions_state($db, $con, $log_file)
{
    $query = "select partition_name, table_rows from information_schema.partitions \n\t\twhere table_name = 'xhprof_blob_30min' and table_schema = '{$db}'";
    $res = mysql_query_p($query, $con, $log_file);
    $msg = "<partition_name, no_of_rows>";
    while ($row = mysql_fetch_assoc($res)) {
        $p_name = $row['partition_name'];
        $table_rows = $row['table_rows'];
        $msg = $msg . ", <{$p_name}, {$table_rows}>";
    }
    log_msg($msg, $log_file);
}