Authored by wuxiao

MqXhprof.php数据库连接

... ... @@ -14,7 +14,12 @@ require_once __DIR__ . '/xhprof.io/xhprof/classes/data.php';
while (true){
echo "Start a new checking\n";
if ($logfiles = glob($Config->performance_dir.'/xhprof*')){
try{
if (empty($pdo)){
throw new \Exception;
}
$pdo->query('show processlist');
}catch(\Exception $e){
$pdo = new PDO("mysql:dbname=xhprof.io;host={$Config->mysql_host};port={$Config->mysql_port};charset=utf8", $Config->mysql_user, $Config->mysql_pass);
$xhprof_data_obj = new \ay\xhprof\Data($pdo);
}
... ... @@ -35,8 +40,11 @@ while (true){
if (!is_array($xhprof_data = json_decode($log['data']['context'],true))){
continue;
}
if (isset($log['data']['_SERVER'])){
list($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']) = array($log['data']['_SERVER']['HTTP_HOST'], $log['data']['_SERVER']['REQUEST_URI'], $log['data']['_SERVER']['REQUEST_METHOD']);
if (isset($log['data']['_SERVER']) && is_array($__SERVER = json_decode($log['data']['_SERVER'],true))){
$_SERVER['HTTP_HOST'] = $__SERVER['HTTP_HOST'];
$_SERVER['REQUEST_URI'] = $__SERVER['REQUEST_URI'];
$_SERVER['REQUEST_METHOD'] = $__SERVER['REQUEST_METHOD'];
@$_SERVER['HTTPS'] = $__SERVER['HTTPS'];
}else{
$_SERVER['HTTP_HOST'] = $_SERVER['REQUEST_URI'] = $_SERVER['REQUEST_METHOD'] = '';
}
... ...
... ... @@ -40,6 +40,9 @@ while true;do
#monitor "$python $pwd/MqClient.py"
monitor "$python $pwd/GoMqClient.py"
#xhprof.io
monitor "$php -f $pwd/MqXhprof.php"
sleep 5
done
... ...