当前位置: 首页>>代码示例>>PHP>>正文


PHP load_game_config函数代码示例

本文整理汇总了PHP中load_game_config函数的典型用法代码示例。如果您正苦于以下问题:PHP load_game_config函数的具体用法?PHP load_game_config怎么用?PHP load_game_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load_game_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modify_hostgroup_in_db

function modify_hostgroup_in_db($final_array)
{
    global $server_cfg, $game;
    foreach ($final_array as $regex => $config) {
        if (!isset($config["class"])) {
            $final_array[$regex] = "";
        }
    }
    $conf_all = parse_ini_file($server_cfg["rs_conf_file"], true);
    $conf = $conf_all["DB"];
    $db_server = $conf["host"];
    $db_user = $conf["user"];
    $db_pass = $conf["password"];
    $db_name = $conf["database"];
    $mysql_pdo = new PDO("mysql:host={$db_server};dbname={$db_name}", $db_user, $db_pass);
    if (!$mysql_pdo) {
        print "Failed to create new mysql PDO\n";
        return 1;
    }
    $game_cfg = load_game_config($game);
    $deploy_id = $game_cfg["deployIDs"][0];
    foreach ($final_array as $regex => $metric) {
        $mysql_regex = str_replace(".*", "%", $regex);
        $hostgroup = $metric['hostgroup'];
        $query = "update instances set hostgroup='{$hostgroup}' where hostname like '{$mysql_regex}' and deploy_id={$deploy_id}";
        $stmt = $mysql_pdo->prepare($query);
        $stmt->execute();
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:29,代码来源:dump_file.php

示例2: main

function main($server_cfg)
{
    $options = get_options();
    if (isset($options['g']) && $options['g'] !== '') {
        $game_names = explode(",", $options['g']);
    } else {
        $game_names = $server_cfg['game_list'];
    }
    foreach ($game_names as $game) {
        zpm_preamble($game);
        $game_cfg = load_game_config($game);
        $retval = null;
        // refs will start failing in 5.3.x if not declared
        $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null ";
        $output = system($cleanup, $retval);
        if ($retval != 0) {
            error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
            continue;
        }
        $arrays_to_id = get_array_id_map($server_cfg, $game_cfg);
        foreach ($arrays_to_id as $array => $id) {
            $game_cfg = load_game_config($game, $id);
            $cleanup = "/usr/local/zperfmon/bin/clean.sh -g " . $game_cfg['name'] . " > /dev/null ";
            $output = system($cleanup, $retval);
            if ($retval != 0) {
                error_log("Couldn`t cleanup game {$game}", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
                continue;
            }
        }
        zpm_postamble($game);
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:32,代码来源:clean.php

示例3: main

function main($server_cfg)
{
    if (isset($_GET['game'])) {
        $game = $_GET['game'];
    } else {
        echo "Game name is invalid or not set \n";
        exit;
    }
    $game_cfg = load_game_config($game);
    $deploy_id = $game_cfg["deployIDs"][0];
    # Getting the distinct hostgroups for the inputed game
    $conf_all = parse_ini_file($server_cfg["rs_conf_file"], true);
    $conf = $conf_all["DB"];
    $db_server = $conf["host"];
    $db_user = $conf["user"];
    $db_pass = $conf["password"];
    $db_name = $conf["database"];
    $mysql_pdo = new PDO("mysql:host={$db_server};dbname={$db_name}", $db_user, $db_pass);
    if (!$mysql_pdo) {
        print "Failed to create new mysql PDO\n";
        return 1;
    }
    $regex = $_GET["regex"];
    $regex = str_replace(".*", '%', $regex);
    $query = "select hostname from instances where hostname like '{$regex}' and deploy_id={$deploy_id}";
    $stmt = $mysql_pdo->prepare($query);
    $stmt->execute();
    $hosts = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $count_hostnames = array();
    foreach ($hosts as $value) {
        $count_hostnames["hosts"][] = $value["hostname"];
    }
    $count_hostnames["count"] = count($count_hostnames["hosts"]);
    echo json_encode($count_hostnames);
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:35,代码来源:fetch_hosts.php

示例4: extract_functions

function extract_functions($files, $game_name, $run_id, $aggregate_dir)
{
    // XXX: xhprof depends on this global for doing entry counts
    global $display_calls;
    $display_calls = true;
    $functions_to_extract = array("MC::set", "MC::get", "ApcManager::get", "ApcManager::set", "serialize", "unserialize", "AMFBaseSerializer::serialize", "AMFBaseDeserializer::deserialize");
    if ($game_cfg = load_game_config($game_name)) {
        //$game_cfg = $game_cfg[$game_name];
        if (isset($game_cfg["tracked_functions"])) {
            $functions_to_extract = $game_cfg["tracked_functions"];
        }
    }
    $prof_obj = new XHProfRuns_Default();
    $runs = xhprof_aggregate_runs_list($prof_obj, $files);
    if ($runs['raw']) {
        $aggregate = $runs['raw'];
    } else {
        return;
    }
    # keep this in sync with the aggregate_files
    # $aggregate_file_name = "{$run_id}.xhprof";
    $overall_totals = null;
    $flattened_profile = xhprof_compute_flat_info($aggregate, $overall_totals);
    $interesting_funcs = extract_interesting_functions($flattened_profile, $functions_to_extract);
    $top_funcs = get_top_functions($flattened_profile, 5);
    $xhprof = array("interesting" => $interesting_funcs, "top functions" => $top_funcs, "files" => $files);
    file_put_contents("{$aggregate_dir}/{$run_id}.extract", serialize($xhprof));
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:28,代码来源:aggregate.php

示例5: get_pie

function get_pie($game_name, $period = "day", $tstamp = null, $metrics = array("excl_wt" => "Exclusive Wall time", "excl_cpu" => "Exclusive CPU time"), $how_many = 6, $profile = null)
{
    global $server_cfg;
    $game_cfg = load_game_config($game_name);
    //$game_cfg = $game_cfg["$game_name"];
    if ($profile != null) {
        $period = "absolute";
    }
    switch ($period) {
        case "day":
            $prof_path = sprintf($server_cfg["daily_profile"], $game_cfg["name"]);
            break;
        case "30min":
            $prof_path = sprintf($server_cfg["daily_upload_directory"], $game_cfg["name"]);
            break;
        case "absolute":
            break;
        default:
            echo "Unsupported period \\'{$period}\\' for get_pie()";
            error_log("Unsupported period \\'{$period}\\' for get_pie()");
            return null;
    }
    if ($period != "absolute") {
        // Find all aggregate profiles in dir and take the last
        $profile_list = glob("{$prof_path}/*all.xhprof");
        if (empty($profile_list)) {
            echo "no profile in {$period} {$prof_path}/*.all.xhprof";
            return null;
        }
        $profile = end($profile_list);
    }
    return get_top_functions($profile, $metrics, $how_many);
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:33,代码来源:profilepie.inc.php

示例6: main

function main($server_cfg)
{
    $options = get_options($server_cfg);
    foreach ($options['games'] as $game) {
        zpm_preamble($game);
        $game_cfg = load_game_config($game);
        if (!$game_cfg) {
            error_log("Daily job: Failed to load config for {$game}\n", 3, sprintf($server_cfg['log_file'], $game));
            continue;
        }
        // log_file and logger object are used by all child functions.
        $game_cfg['log_file'] = sprintf($server_cfg['log_file'], $game);
        $game_cfg['logger'] = new Logger($server_cfg, $game_cfg);
        $job = $options['job'];
        if ($job == "both" or $job == "daily") {
            process_daily($server_cfg, $game_cfg, $options['timeslot'], $options['period']);
        }
        //performance report
        /*
        		if ($job == "both" or $job == "report") {
        			generate_report($server_cfg, $game_cfg,
        					$options['timeslot'], $options['period']);
        		}*/
        zpm_postamble($game);
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:26,代码来源:daily_job.php

示例7: main

function main($server_cfg)
{
    $options = get_options($server_cfg);
    foreach ($options['games'] as $game) {
        zpm_preamble($game);
        $game_cfg = load_game_config($game);
        if (!$game_cfg) {
            error_log("Daily job: Failed to load config for {$game}\n", 3, sprintf($server_cfg['log_file'], $game));
            continue;
        }
        // log_file and logger object are used by all child functions.
        $game_cfg['log_file'] = sprintf($server_cfg['log_file'], $game);
        $game_cfg['logger'] = new Logger($server_cfg, $game_cfg);
        $job = $options['job'];
        //instance detail report per game
        if ($job == "both" or $job == "report") {
            InstanceReport::generate_detail_report($server_cfg, $game_cfg, $options['timeslot'], $options['period']);
        }
        zpm_postamble($game);
    }
    //instance summary report for all games
    $job = $options['job'];
    if ($job == "both" or $job == "report") {
        InstanceReport::generate_summary_report($server_cfg, $options['timeslot'], $options['period']);
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:26,代码来源:daily_instance_report_job.php

示例8: get_config_file

 public function get_config_file($game)
 {
     $game_cfg = load_game_config($game);
     if (isset($game_cfg['cloud_name']) && $game_cfg['cloud_name'] == 'zcloud') {
         return $this->server_cfg['common_config_zcloud_file'];
     } else {
         return $this->server_cfg['common_config_file'];
     }
 }
开发者ID:shourya07,项目名称:zperfmon,代码行数:9,代码来源:yml_conf.inc.php

示例9: scan_game_cfgs

function scan_game_cfgs($server_cfg)
{
    $map = array();
    foreach ($server_cfg["game_list"] as $game) {
        $gcfg = load_game_config($game);
        $deploy_id = $gcfg['deployIDs'][0];
        $map[$deploy_id] = $game;
    }
    return $map;
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:10,代码来源:game_deploy_map.php

示例10: get_ips

 private function get_ips()
 {
     $this->game_cfg = load_game_config($this->game);
     $deploy_id = $this->game_cfg['deployIDs'][0];
     $query = "select array_id, private_ip from instances where deploy_id={$deploy_id} and array_id != 0";
     $stmt = $this->prepare($query);
     if ($stmt) {
         $result = $this->fetchAll($stmt, array());
         foreach ($result as $item) {
             $array_id = $item['array_id'];
             $this->ip_list[$array_id][] = $item['private_ip'];
         }
     }
 }
开发者ID:shourya07,项目名称:zperfmon,代码行数:14,代码来源:xhprof_update.php

示例11: splitarraywise

function splitarraywise($server_cfg, $ip_list, $game_name, $time_slot)
{
    $game_cfg = load_game_config($game_name);
    $rs = new RightScale($server_cfg, $game_cfg);
    $mapping = $rs->get_array_ip_mapping();
    $return = array();
    foreach ($ip_list as $ip) {
        $dir_base_path = sprintf($server_cfg["root_upload_directory"], $game_name);
        $base_ip_dir = $dir_base_path . $time_slot . "/" . $server_cfg['profile_upload_directory'];
        $ip_dir = $base_ip_dir . "/" . $ip;
        //$filelist = scandir($ip_dir);
        $array_id = $mapping[$ip];
        // To prevent game_ folder to be created due to 5 minute processing
        if (!isset($array_id) || $array_id == '') {
            continue;
        }
        $return[$array_id][] = $ip;
        $dir_base_path_array = sprintf($server_cfg["root_upload_directory"], $game_name . "_" . $array_id);
        //creating the timeslot directory
        if (!is_dir($dir_base_path_array . $time_slot)) {
            mkdir($dir_base_path_array . $time_slot, 0777, true);
        }
        //creating the xhprof directory
        if (!is_dir($dir_base_path_array . $time_slot . "/" . $server_cfg['profile_upload_directory'])) {
            mkdir($dir_base_path_array . $time_slot . "/" . $server_cfg['profile_upload_directory'], 0777, true);
        }
        $base_ip_dir_array = $dir_base_path_array . $time_slot . "/" . $server_cfg['profile_upload_directory'];
        $ip_directory_array = $base_ip_dir_array . "/" . $ip;
        // Check if symlink exists already. In case of frequent call of the function in a timeslot
        if (!is_dir($ip_directory_array)) {
            symlink($ip_dir, $ip_directory_array);
        }
        if (!file_exists($base_ip_dir_array . "/" . ".profiles")) {
            // put the ip uploading ip addresses which should be segragated while massaging.
            file_put_contents("{$base_ip_dir_array}/.profiles", $ip, FILE_APPEND | LOCK_EX);
            //touch(($base_ip_dir_array."/".".profiles"));
            error_log(".profiles created" . "\n" . sprintf($server_cfg['log_file'], $game_cfg['name']));
        }
        if (!file_exists($base_ip_dir_array . "/" . ".slowpages")) {
            touch($base_ip_dir_array . "/" . ".slowpages");
            error_log(".slowpages created" . "\n" . sprintf($server_cfg['log_file'], $game_cfg['name']));
        }
        if (!file_exists($base_ip_dir_array . "/" . ".apache_stats")) {
            touch($base_ip_dir_array . "/" . ".apache_stats");
            error_log(".apache_stats created" . "\n" . sprintf($server_cfg['log_file'], $game_cfg['name']));
        }
    }
    return $return;
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:49,代码来源:array_wise_split.php

示例12: __construct

 public function __construct($server_cfg, $game, $slack_now = false)
 {
     $cfg = get_eu_cfg($server_cfg['eu_conf_file']);
     $db_server = $cfg["db_host"];
     $db_user = $cfg["db_user"];
     $db_pass = $cfg["db_pass"];
     $db_name = $cfg["db_name"];
     $this->table = $cfg["table"];
     $this->game = $game;
     $this->game_cfg = load_game_config($game);
     $this->server_cfg = $server_cfg;
     parent::__construct($db_server, $db_user, $db_pass, $db_name);
     $this->max_metric = $this->get_max_metric($slack_now);
     $this->rs = new Rightscale($server_cfg, $game);
 }
开发者ID:shourya07,项目名称:zperfmon,代码行数:15,代码来源:instance-eu-adapter.php

示例13: main

function main($server_cfg)
{
    $options = get_options();
    if (isset($options['g']) && $options['g'] !== '') {
        $game_names = explode(",", $options['g']);
    } else {
        $game_names = $server_cfg['game_list'];
    }
    foreach ($game_names as $game_name) {
        zpm_preamble($game_name);
        try {
            $game_cfg = load_game_config($game_name);
            //$game_cfg = $game_cfg[$game_name];
            $now = time();
            $query_period = $now - 5 * 60;
            // 5 minutes ago
            if (isset($game_cfg['splunk_url'])) {
                $splunk_url = $game_cfg['splunk_url'];
                $splunk_user = $game_cfg['splunk_user'];
                $splunk_pass = $game_cfg['splunk_password'];
                $splunk_queries = $game_cfg['splunk_queries'];
                $splunk_collector = new SplunkCollector($splunk_url, $splunk_user, $splunk_pass);
                $splunk_store = new SplunkAdapter($game_cfg);
                foreach ($splunk_queries as $query_name => $query) {
                    $results = $splunk_collector->run_query($query, $query_period);
                    if (is_array($results)) {
                        $count = $results[0]["count"];
                        $splunk_store->store_splunk_count($now, $query_name, $count);
                    } else {
                        echo "Could not fetch {$query_name} for {$game_name}\n";
                    }
                }
            }
        } catch (Exception $e) {
        }
        zpm_postamble($game_name);
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:38,代码来源:get_splunk_metrics.php

示例14: main

function main($server_cfg)
{
    $options = getopt("g:");
    $game = $options['g'];
    $game_cfg = load_game_config($game);
    $hostConfigObj = new HostgroupConfig($server_cfg, $game);
    $rsObj = new RightScale($server_cfg, $game_cfg);
    $array_id_name = array_values($rsObj->get_array_to_arrayid_mapping());
    $config_col_names = $hostConfigObj->get_config_column_names();
    $xhprofModelObj = new XhprofModel($server_cfg, $game_cfg, false);
    // add columns for both the tables
    $tables = array("vertica_stats_30min", "vertica_stats_daily");
    echo "adding columns for {$game}:\n";
    foreach ($tables as $table) {
        $result = add_missing_columns($config_col_names, $table, $xhprofModelObj);
    }
    foreach ($array_id_name as $array_id) {
        echo "adding columns for {$game}:{$array_id}:\n";
        $game_cfg = load_game_config($game, $array_id);
        $xhprofModelObj = new XhprofModel($server_cfg, $game_cfg, false);
        foreach ($tables as $table) {
            $result = add_missing_columns($config_col_names, $table, $xhprofModelObj);
        }
    }
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:25,代码来源:vertica_table_add_column.php

示例15: move_slow_page

function move_slow_page($server_cfg, $game_name, $time_slot = '*', &$top5)
{
    $output = array();
    $root_upload_directory = sprintf($server_cfg['root_upload_directory'], $game_name);
    //checking if the input game_name corresponds to a array of a parent game
    try {
        $game_cfg = array();
        if (!in_array($game_name, $server_cfg["game_list"])) {
            /*$game_split = split("_", $game_name);
            		$game_name_array = array();
            		for ( $counter = 0; $counter < count($game_split)-1; $counter ++) {
            			array_push($game_name_array, $game_split[$counter]);
            		}
            		$game_name = implode($game_name_array);
            		$array_id = $game_split[count($game_split)-1];*/
            $last_tok_index = strrpos($game_name, "_");
            $array_id = substr($game_name, $last_tok_index + 1, strlen($game_name) - $last_tok_index);
            $game_name = substr($game_name, 0, $last_tok_index);
            $game_cfg = load_game_config($game_name, $array_id);
        } else {
            $game_cfg = load_game_config($game_name);
        }
        $game_name = $game_cfg["name"];
        if (!$game_cfg) {
            error_log("configuration for " . $game_name . " is not loaded\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
            return $output;
        }
    } catch (Exception $e) {
        error_log("configuration loading for {$game_name} failed\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
        error_log("Exception says: " . $e->getMessage() . "\n", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
    }
    $slowpage_markers = glob("{$root_upload_directory}{$time_slot}/" . $server_cfg['profile_upload_directory'] . "/.slowpages", GLOB_BRACE);
    if (empty($slowpage_markers)) {
        error_log("No slowpage for {$time_slot}\n", 3, sprintf($server_cfg['log_file'], $game_name));
        return $output;
    }
    foreach ($slowpage_markers as $marker) {
        $profile_upload_directory = dirname($marker);
        $timestamp = (int) (basename(dirname(dirname($marker))) * 1800);
        error_log("slow pages for {$profile_upload_directory}\n", 3, sprintf($server_cfg['log_file'], $game_name));
        foreach (glob("{$profile_upload_directory}/*php") as $page_dir) {
            if (!is_dir($page_dir)) {
                continue;
            }
            scan($server_cfg, $game_name, $game_cfg["slow_page_threshold"], $page_dir, $time_slot, $output, $top5);
        }
    }
    error_log(sprintf("in move_slow_page top5 list has %d lines\n", count($top5)), 3, sprintf($server_cfg['log_file'], $game_name));
    return $output;
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:50,代码来源:move_slowpages.php


注:本文中的load_game_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。