예제 #1
0
 function __construct($server_cfg)
 {
     $conf = get_rs_config($server_cfg["rs_conf_file"]);
     $db_server = $conf["host"];
     $db_user = $conf["user"];
     $db_pass = $conf["password"];
     $db_name = $conf["database"];
     parent::__construct($db_server, $db_user, $db_pass, $db_name);
     $this->server_cfg = $server_cfg;
 }
예제 #2
0
 public function make_array_games()
 {
     $deploy_array = $this->game_cfg["deployIDs"];
     $deploy_id = $deploy_array[0];
     $hostConfigObj = new HostgroupConfig($this->server_cfg, $this->game_cfg["name"]);
     $hostgroup_config = $hostConfigObj->load_hostgroup_config();
     $class_hostgroups = $hostConfigObj->get_hostgroup_per_class($hostgroup_config);
     $array_names_str = implode(",", array_map("put_quotes", $class_hostgroups['web']));
     $query = "select distinct(array_id) from instances where deploy_id = (:deploy_id) and hostgroup in ( {$array_names_str} ) ";
     $parameters = array("deploy_id" => array($deploy_id, PDO::PARAM_INT));
     $stmt = $this->prepare($query);
     $rows = $this->fetchAll($stmt, $parameters);
     $arrays = array();
     foreach ($rows as $row) {
         $database_check = 0;
         $conf = get_rs_config($this->server_cfg["rs_conf_file"]);
         $db_server = $conf["host"];
         $db_user = $conf["user"];
         $db_pass = $conf["password"];
         $db_name = "zprf_" . $this->game_cfg["name"] . "_" . $row["array_id"];
         try {
             //
             // Information about all databases are stored in information_schema under schemata table
             // A database name is stored under schema_name column of schemata table.
             //
             $pdo = new PDO("mysql:host={$db_server};dbname=information_schema", $db_user, $db_pass);
             $db_query = "select schema_name from schemata where schema_name='{$db_name}'";
             $stmt = $pdo->prepare($db_query);
             $stmt->execute();
             $db_name = $stmt->fetchAll(PDO::FETCH_ASSOC);
             if (empty($db_name)) {
                 echo "Database for " . $this->game_cfg["name"] . "_" . $row["array_id"] . "Does not exists\n";
                 $database_check = 1;
             }
         } catch (Exception $e) {
             error_log("Database doesnt exist for array game {$db_name}\n", 3, sprintf($this->server_cfg['log_file'], $this->game_cfg['name']));
         }
         $retval = null;
         if (!$this->check_game_exist($row["array_id"]) or $database_check == 1) {
             if ($row["array_id"] != "") {
                 $cmd = "yes | /usr/local/bin/zperfmon-add-game " . $this->game_cfg["name"] . " " . $row["array_id"] . " 2>&1 > /tmp/split-log &";
             }
             $output = exec($cmd, $retval);
             array_push($arrays, $row["array_id"]);
             if ($retval != 0) {
                 error_log("Couldn`t  make game with  {$cmd}\n{$retval}\n{$output}\n", 3, sprintf($this->server_cfg['log_file'], $this->game_cfg['name']));
                 continue;
             }
         }
     }
 }
예제 #3
0
 public function __construct($server_cfg, $game)
 {
     $cfg = get_rs_config($server_cfg['rs_conf_file']);
     $db_server = $cfg["db_host"];
     $db_user = $cfg["db_user"];
     $db_pass = $cfg["db_pass"];
     $db_name = $cfg["db_name"];
     $this->server_cfg = $server_cfg;
     $this->game = $game;
     parent::__construct($db_server, $db_user, $db_pass, $db_name);
     $this->ip_list = array();
     // Query rightscale DB to get array wise IPs for 'game'
     $this->get_ips();
     // Apply selection criteria and find profiling candidate IPs
     $this->balance_ips();
 }