function scan_and_insert($server_cfg, $game_cfg, $dir_path) { $xhprof_slow_dir = sprintf($server_cfg["slow_page_dir"], $game_cfg["name"]); $xhprof_symlinks = array(); foreach (glob("{$xhprof_slow_dir}/*") as $lnk) { if (is_link($lnk)) { $xhprof_symlinks[readlink($lnk)] = $lnk; } } foreach (scandir($dir_path) as $profile) { # Basic duplicate check # if the symlink has already been established, bail out if (array_key_exists("{$dir_path}/{$profile}", $xhprof_symlinks)) { continue; } $prof_components = explode(":", $profile); # # Basic check to see if this file was created by # zperfmon client. # if (count($prof_components) < 5) { continue; } if ($prof_components[count($prof_components) - 1] != 'xhprof') { continue; } if (count($prof_components) == 6) { unset($prof_components[3]); $prof_components = array_values($prof_components); } $page_time = slow_page($dir_path, $profile, $game_cfg["slow_page_threshold"], $flat_profile); if ($page_time == 0) { continue; } $query_res = query_insert_page($server_cfg, $game_cfg, $prof_components, "{$dir_path}/{$profile}", $flat_profile, $page_time); if ($query_res >= 0) { $game_cfg['logger']->log("insert_slowpage", "slow_pages for {$dir_path}/{$profile} inserted", Logger::INFO); } else { if ($query_res != 0) { $game_cfg['logger']->log("insert_slowpage", "slow_pages for {$dir_path}/{$profile} not inserted", Logger::ERR); } } } }
function scan($server_cfg, $game_name, $slow_page_threshold, $dir_path, $time_slot, &$output, &$top5) { $xhprof_slow_dir = sprintf($server_cfg["slow_page_dir"], $game_name); $xhprof_symlinks = array(); foreach (glob("{$xhprof_slow_dir}/*") as $lnk) { if (is_link($lnk)) { $xhprof_symlinks[readlink($lnk)] = $lnk; } } error_log(sprintf("top5 list has %d lines\n", count($top5)), 3, sprintf($server_cfg['log_file'], $game_name)); foreach (scandir($dir_path) as $profile) { # Basic duplicate check # if the symlink has already been established, bail out if (array_key_exists("{$dir_path}/{$profile}", $xhprof_symlinks)) { continue; } $prof_components = explode(":", $profile); # # Basic check to see if this file was created by # zperfmon client. # if (count($prof_components) < 5) { continue; } if ($prof_components[count($prof_components) - 1] != 'xhprof') { continue; } $page_time = slow_page($dir_path, $profile, $slow_page_threshold, $flat_profile, $top5, $game_name, $server_cfg); if ($page_time == 0) { continue; } $query_res = query_move_slow_page($server_cfg, $game_name, $prof_components, "{$dir_path}/{$profile}", $flat_profile, $page_time, $time_slot, $output); } error_log(sprintf("in scan top5 list has %d lines\n", count($top5)), 3, sprintf($server_cfg['log_file'], $game_name)); }