function write_to_hostgroup_yml() { global $server_cfg, $game, $current_yaml_file; // Creating a copy of current yaml file $hostgroupConfigObj = new HostgroupConfig($server_cfg, $game); $current_yaml_file = $hostgroupConfigObj->load_hostgroup_config(); $final_array = json_decode($_POST["json_final"], true); foreach ($final_array as $regex => $config) { if (!isset($config["class"])) { $final_array[$regex] = ""; } } $file_path = sprintf($server_cfg["hostgroups_config"], $game); $yaml_str = Spyc::YAMLDump($final_array); file_put_contents($file_path, $yaml_str) or die("Unable to modify hostgroup.yml file. Exiting...."); }
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); } } }
<div class="tags-wrapper left"> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> <div id="tab-eu-dialog" title="Profile Info"></div> <div id="tab-eu-table" class="yui-skin-sam"></div> <?php include_once 'yml_conf.inc.php'; include_once 'server.cfg'; $game = $_GET['game']; $obj = new HostgroupConfig($server_cfg, $game); $row = array(); $mb_row = $obj->get_master_hostgroups(array('mb')); $row = array_merge($row, $mb_row); $mc_row = $obj->get_master_hostgroups(array('mc')); $row = array_merge($row, $mc_row); ?> <script> (function() { var game = $('#GameList option:selected').val(); var arrayid = $('#ArrayList option:selected').val(); var gameParam = "game=" + game; var row = <?php echo json_encode($row); ?> ;
public function get_host_count_per_class($deploy_id, $game_name) { $hostConfigObj = new HostgroupConfig($this->server_cfg, $game_name); $hostgroup_config = $hostConfigObj->load_hostgroup_config(); $params = array(); $return = array(); foreach ($hostgroup_config as $name => $conf) { if (!isset($conf['class'])) { continue; } $like = str_replace(".*", "%", $name); $pool = str_replace(".*", "", $name); if (isset($conf['hostname_like'])) { //until we have a fix hostgroup corresponding to each hostname $like = $conf['hostname_like']; } if (isset($conf['hostname_not_like'])) { //until we have a fix hostgroup corresponding to each hostname $not_like = $conf['hostname_not_like']; } $query = @"select count(hostname) as count from instances where hostname like '{$like}' and \n\t\t\t\t\thostname not like '{$not_like}' and hostname not like '%bad' and status!='STOPPED' and deploy_id={$deploy_id}"; $stmt = $this->prepare($query); $rows = $this->fetchAll($stmt, $params); $tmp = array(); if (!isset($return[$conf['class']])) { $return[$conf['class']] = array(); } $return[$conf['class']][$pool] = $rows[0]['count']; } foreach ($return as $class => $pool) { $total = 0; foreach ($pool as $name => $count) { $total += $count; } $return[$class]['total'] = $total; } return $return; }
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # header("Content-Type:text/plain"); include_once 'server.cfg'; include_once 'yml_conf.inc.php'; $game = $_GET['game']; if (empty($game)) { return; } #$common_config_file = $server_cfg['common_config_file']; $hostgroupConfigObj = new HostgroupConfig($server_cfg, $game); $common_config_file = $hostgroupConfigObj->get_config_file($game); $game_config_file = sprintf($server_cfg['hostgroups_config'], $game); $str_yaml = null; if (file_exists($common_config_file)) { $str_yaml = file_get_contents($common_config_file); } if (file_exists($game_config_file)) { $str_yaml .= file_get_contents($game_config_file); } echo $str_yaml;
"/></td> <td><input type="submit" name="submit" value="Submit" id="tag_submit"/></td> </tr> </table> </div> </form> <?php include_once "slack_api.php"; function get_instance_count_slack_offset($game_name) { $slack_api = json_decode(calculate_slack($game_name, false), true); return $slack_api; } $metric_array_map = array("common_web_eu" => "web", "common_mc_eu" => "mc", "common_mb_eu" => "mb", "common_db_eu" => "db", "common_proxy_eu" => "proxy", "common_msched_eu" => "msched", "common_mqueue_eu" => "mqueue", "common_nagios_eu" => "nagios", "common_consumer_eu" => "consumer", "common_gib_web" => "gib"); $hostgroupConfigObj = new HostgroupConfig($server_cfg, $game); $yaml_array = $hostgroupConfigObj->load_hostgroup_config(); $final_yaml_array = array(); $common_config_array = array(); foreach ($yaml_array as $key => $yaml_str) { if (!isset($yaml_str["class"]) and $metric_array_map[$key] != NULL) { $common_config_array[$metric_array_map[$key]] = $yaml_str; continue; } $final_yaml_array[$key] = $yaml_str; if ($final_yaml_array[$key]['hostgroup'] == '') { $final_yaml_array[$key]['hostgroup'] = str_replace(".*", '', $key); } } $json_final_array = json_encode($final_yaml_array); $json_common_config_array = json_encode($common_config_array);
private function load_config($game) { $return = array(); if (empty($game)) { return $return; } $hostgroupConfigObj = new HostgroupConfig($this->server_cfg, $game); return $hostgroupConfigObj->load_hostgroup_config(); }
public function get_configs() { $hostgroupConfigObj = new HostgroupConfig($this->server_cfg, $this->game); //$common_config = $this->server_cfg['common_config_file']; //$hostgroup_config = sprintf($this->server_cfg['hostgroups_config'], $this->game); //$str_yaml = @file_get_contents($common_config); //$str_yaml .= @file_get_contents($hostgroup_config); //$config = load_config($str_yaml); //return $config; return $hostgroupConfigObj->load_hostgroup_config(); }
} $report_cfg = get_report_cfg($server_cfg['report_conf_file']); $xhprofModelObject = new XhProfModel($server_cfg, $report_cfg, false, false); $result = $xhprofModelObject->generic_execute_get_query("get_instance_class_name", array()); foreach ($result as $value) { $db_class[$value['class_id']] = $value['class_name']; } /* * load config for all the games */ $games = $server_cfg['game_list']; $class = array(); /* * cycle through all games and find all class name by reading hostgroup */ foreach ($games as $game) { $hostgroup = new HostgroupConfig($server_cfg, $game); $class = array_merge($class, $hostgroup->get_class_name()); } /* * find diff between these two array and insert into database if any new class is found in hostgroup files of any game */ $diff = array_diff(array_unique($class), $db_class); $max = count($db_class); if (count($diff) > 0) { foreach ($diff as $name => $value) { $max += 1; $xhprofModelObject->generic_execute_get_query("insert_instance_class_name", array('table' => 'instance_class_name', 'max' => $max, 'value' => $value)); } } zpm_postamble("");
public function get_hosts_config($game_cfg) { /* $config_dir = sprintf($this->server_cfg['config_directory'], $game_cfg['name']); */ $hostgroupConfigObj = new HostgroupConfig($this->server_cfg, $game_cfg['name']); /*$common_config = $this->server_cfg['common_config_file']; $game_config = sprintf($this->server_cfg['hostgroups_config'], $game_cfg['name']); $str_yml = @file_get_contents($common_config); $str_yml .= @file_get_contents($game_config); $cfg = Spyc::YAMLLoad($str_yml); return $cfg; */ return $hostgroupConfigObj->load_hostgroup_config(); }