function store_dau() { $rows = array(); $tmp_file = fopen($_FILES['DAU']['tmp_name'], "r"); while ($row = fgetcsv($tmp_file, 0, "\t")) { $rows[] = $row; } $daustore = new DAUAdapter(); $daustore->store_dau($rows); shadow_upload($_FILES['DAU']['tmp_name']); }
function insert_rightscale_data($server_cfg, $game_cfg, $time_slots = '*') { // TODO take the names from config and expand table as and when new machine class is added to config $machine_class_default = array('web_count' => 0, 'mb_count' => 0, 'mc_count' => 0, 'db_count' => 0, 'queue_count' => 0, 'proxy_count' => 0, 'admin_count' => 0); $game_name = $game_cfg["name"]; $table = $game_cfg['db_stats_table']; $gid = $game_cfg['gameid']; // to query for the dau_5min table and to insert into stats_30min; $snid = $game_cfg['snid'] ? $game_cfg['snid'] : null; $cid = $game_cfg['cid'] ? $game_cfg['cid'] : null; $deploy_array = $game_cfg['deployIDs']; $deploy_id = $deploy_array[0]; // // get the max value of the supplied timeslots // expects that time_slots are given as follows // {ts1,ts2} // preg_match("/\\{(.*)\\}/", $time_slots, $m); $timeslot = max(explode(",", $m[1])); if (empty($timeslot)) { $game_cfg['logger']->log("insert_bd_metric", "null is given as timeslot", Logger::ERR); error_log("null is given as timeslots", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); return; } $timestamp = $timeslot * 1800; $dauObj = new DAUAdapter(); $dau = $dauObj->get_timed_dau($timestamp, $gid, $snid, $cid); $rsObj = new RightScale($server_cfg, $game_cfg); $web_count = null; if (isset($game_cfg['id'])) { $web_count = $rsObj->get_host_count_per_pool($game_cfg['id'], $deploy_id); $game_name = $game_cfg['parent']; // to query other machine counts } $machine_counts = $rsObj->get_host_count_per_class($deploy_id, $game_name); $counts_array = get_counts($machine_class_default, $machine_counts, $web_count); $query = create_query($table, $timestamp, $dau, $counts_array, $gid); $queries = array($query); $query_res = execute_queries($server_cfg, $game_cfg, $queries); if ($query_res == 0) { $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " successfully inserted", Logger::INFO); error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } else { $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " not inserted", Logger::ERR); error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } }
function get_dau() { global $game_cfg, $server_cfg; $gid = $game_cfg["gameid"]; $snid = $this->game_cfg["snid"] ? $this->game_cfg["snid"] : null; $cid = $this->game_cfg["cid"] ? $this->game_cfg["cid"] : null; $end_time = time(); $start_time = $end_time - 1800; $daustore = new DAUAdapter(); $dau = $daustore->get_dau($gid, $start_time, $end_time, $snid, $cid); $last2 = array_splice($dau, -2, 2); if (count($last2) != 2) { return array(-1, -1); } return get_column_vector($last2, "DAU"); }