/**
  * returns a BenchmarkArchiver object based on command line arguments
  * @return BenchmarkArchiver
  */
 public static function &getArchiver()
 {
     $archiver = NULL;
     $options = parse_args(array('store:', 'store_container:', 'store_endpoint:', 'store_insecure', 'store_key:', 'store_prefix:', 'store_public', 'store_region:', 'store_secret:', 'v' => 'verbose'), NULL, 'save_');
     merge_options_with_config($options, BenchmarkDb::BENCHMARK_DB_CONFIG_FILE);
     $impl = 'BenchmarkArchiver';
     switch ($options['store']) {
         case 'azure':
             $impl .= 'Azure';
             break;
         case 'google':
             $impl .= 'Google';
             break;
         case 's3':
             $impl .= 'S3';
             break;
         default:
             $err = '--store ' . $options['store'] . ' is not valid';
             break;
     }
     // invalid --store argument
     if (isset($err)) {
         print_msg($err, isset($options['verbose']), __FILE__, __LINE__, TRUE);
         return $archiver;
     }
     require_once sprintf('%s/%s.php', dirname(__FILE__), $impl);
     $archiver = new $impl($options);
     $archiver->options = $options;
     if (!$archiver->validate()) {
         $archiver = NULL;
     }
     return $archiver;
 }
Beispiel #2
0
function print_deck_select_table($table, $attributes, $constraints)
{
    array_push($attributes, "id");
    #array_push($attributes, "delete");
    #var_dump($constraints);
    $attr_list_str = implode(', ', $attributes);
    $query = "SELECT {$attr_list_str} FROM {$table}";
    if (!empty($constraints)) {
        $cons_str = mysql_where_str($constraints);
        $query .= " WHERE {$cons_str}";
    }
    #$query .= ";";
    $query .= " ORDER BY name;";
    #print_msg($query);
    $result = mysql_query($query);
    $num = @mysql_numrows($result);
    print_msg("total = {$num}");
    if ($num == 0) {
        return;
    }
    echo "<table>";
    echo "<tr>";
    array_push($attributes, "delete");
    foreach ($attributes as $attr) {
        if ($attr != "id") {
            echo "<th>";
            echo $attr;
            echo "</th>";
        }
    }
    echo "</tr>";
    $i = 0;
    while ($i < $num) {
        $id = mysql_result($result, $i, "id");
        echo "<tr id=\"{$id}\">";
        foreach ($attributes as $attr) {
            if ($attr == "delete") {
                echo "<td>";
                echo "<button name=\"{$id}\">delete</button>";
                echo "</td>";
            } else {
                if ($attr != "id") {
                    $value = mysql_result($result, $i, $attr);
                    echo "<td>";
                    if ($attr == "link") {
                        echo "<a href=\"{$value}\">";
                        echo $value;
                        echo "</a>";
                    } else {
                        echo mysql_result($result, $i, $attr);
                    }
                    echo "</td>";
                }
            }
        }
        echo "</tr>";
        $i++;
    }
    echo "</table>";
}
Beispiel #3
0
function insert_deck_data($dir)
{
    global $DECK_TABLE_NAME;
    $files = scandir($dir);
    $data = array();
    $card = array();
    foreach ($files as $file_name) {
        if ($file_name == "." || $file_name == "..") {
            continue;
        }
        $data["id"] = $file_name;
        $deck_file = read_file("{$dir}/{$file_name}");
        $deck_file_line_arr = explode("\n", $deck_file);
        $deck_head_arr = array_slice($deck_file_line_arr, 0, 3);
        $deck_card_arr = array_slice($deck_file_line_arr, 4);
        $result = deck_get_name_and_creator($deck_head_arr[0]);
        $data["name"] = $result[0];
        $data["creator"] = $result[1];
        $data["link"] = $deck_head_arr[1];
        $data["class"] = deck_get_class($deck_head_arr[2]);
        $card = deck_get_cards($deck_card_arr);
        $data["num"] = deck_count_card($card);
        $new_table_name = create_new_deck($data, $card);
        print_msg("create {$new_table_name}");
    }
}
Beispiel #4
0
function login($id, $passwd, $url)
{
    $dbh = dbconnect();
    $query = "select mem_id,mem_pw from member_data where mem_id='{$id}'";
    $sth = dbquery($dbh, $query);
    if (!$sth) {
        print_msg(mysql_error());
    }
    list($mem_id, $mem_pw) = dbselect($sth);
    dbclose($dbh);
    if (!$mem_id) {
        print_alert("해당 ID가 없습니다.  ", 'back');
    } elseif ($mem_pw != $passwd) {
        print_alert("비밀번호가 틀립니다.  ", 'back');
    } else {
        setcookie("MemberID", $mem_id);
        header("Location: {$url}");
    }
    return;
}
Beispiel #5
0
function check_idnum($idnum)
{
    if (!check_idnum_syntax($idnum)) {
        print_msg("주민등록가 잘못되었습니다.<br>정확히 입력하세요.", 'check_idnum', -1);
    }
    $dbh = dbconnect();
    $idnum2 = substr($idnum, 0, 6) . "-" . substr($idnum, 6, 7);
    $query = "select mem_idnum from member_data where mem_idnum='{$idnum2}'";
    $sth = dbquery($dbh, $query);
    if (!$sth) {
        print_msg(mysql_error());
    }
    list($mem_idnum) = dbselect($sth);
    dbclose($dbh);
    if ($mem_idnum == $idnum2) {
        return false;
    } else {
        return true;
    }
}
Beispiel #6
0
function print_card_select_table($table, $attributes, $constraints)
{
    #var_dump($constraints);
    $attr_list_str = implode(', ', $attributes);
    $query = "SELECT {$attr_list_str} FROM {$table}";
    if (!empty($constraints)) {
        $cons_str = mysql_where_str($constraints);
        $query .= " WHERE {$cons_str}";
    }
    $query .= ";";
    #print_msg($query);
    $result = mysql_query($query);
    $num = @mysql_numrows($result);
    print_msg("total = {$num}");
    if ($num == 0) {
        return;
    }
    echo "<table>";
    echo "<tr>";
    foreach ($attributes as $attr) {
        echo "<th>";
        echo $attr;
        echo "</th>";
    }
    echo "</tr>";
    $i = 0;
    while ($i < $num) {
        echo "<tr>";
        foreach ($attributes as $attr) {
            echo "<td>";
            echo mysql_result($result, $i, $attr);
            echo "</td>";
        }
        echo "</tr>";
        $i++;
    }
    echo "</table>";
}
 /**
  * validation method - may be overriden by sub-classes, but parent method 
  * should still be invoked. returns TRUE if db options are valid, FALSE 
  * otherwise
  * @return boolean
  */
 protected function validate()
 {
     if ($valid = parent::validate()) {
         if (!isset($this->options['db_name'])) {
             $valid = FALSE;
             print_msg('--db_name argument is required for --db bigquery', isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
         } else {
             if ($this->bq() !== NULL) {
                 $valid = TRUE;
                 print_msg('BigQuery connection successful', isset($this->options['verbose']), __FILE__, __LINE__);
             } else {
                 print_msg('BigQuery connection failed', isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             }
         }
     }
     return $valid;
 }
 /**
  * validation method - may be overriden by sub-classes, but parent method 
  * should still be invoked. returns TRUE if db options are valid, FALSE 
  * otherwise
  * @return boolean
  */
 protected function validate()
 {
     if (!isset($this->valid) && parent::validate()) {
         $this->valid = TRUE;
         $validate = array('db_librato_color' => array('color' => TRUE), 'db_librato_display_max' => array('min' => 0), 'db_librato_display_min' => array('min' => 0), 'db_librato_period' => array('min' => 0), 'db_librato_type' => array('option' => array('counter', 'gauge')), 'db_user' => array('required' => TRUE), 'db_pswd' => array('required' => TRUE));
         if ($validated = validate_options($this->options, $validate)) {
             $this->valid = FALSE;
             foreach ($validated as $param => $err) {
                 print_msg(sprintf('--%s is not valid: %s', $param, $err), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             }
         } else {
             $valueCol = 'db_librato_value';
             if (!isset($this->options['db_librato_value'])) {
                 $valueCol = 'db_librato_count';
                 if (!isset($this->options['db_librato_count']) || !isset($this->options['db_librato_sum'])) {
                     $this->valid = FALSE;
                     print_msg(sprintf('If --db_librato_value is not set, both --db_librato_count and --db_librato_sum MUST be specified'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                 } else {
                     if (count($this->options['db_librato_count']) != count($this->options['db_librato_sum'])) {
                         $this->valid = FALSE;
                         print_msg(sprintf('--db_librato_count and --db_librato_sum must be repeated the same number of times'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                     } else {
                         if (isset($this->options['db_librato_name']) && count($this->options['db_librato_name']) != count($this->options['db_librato_count'])) {
                             $this->valid = FALSE;
                             print_msg(sprintf('--db_librato_name and --db_librato_count must be repeated the same number of times'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                         }
                     }
                 }
             } else {
                 if (isset($this->options['db_librato_name']) && count($this->options['db_librato_name']) != count($this->options['db_librato_value'])) {
                     $this->valid = FALSE;
                     print_msg(sprintf('--db_librato_name and --db_librato_value must be repeated the same number of times'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                 } else {
                     if (isset($this->options['db_librato_count']) || isset($this->options['db_librato_sum']) || isset($this->options['db_librato_max']) || isset($this->options['db_librato_min']) || isset($this->options['db_librato_sum_squares'])) {
                         $this->valid = FALSE;
                         print_msg(sprintf('--db_librato_value cannot be set with --db_librato_count, --db_librato_sum, --db_librato_max, --db_librato_min or --db_librato_sum_squares because these parameters are mutually exclusive'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                     }
                 }
             }
             if ($this->valid) {
                 foreach (array('db_librato_aggregate', 'db_librato_color', 'db_librato_count', 'db_librato_description', 'db_librato_display_max', 'db_librato_display_min', 'db_librato_display_name', 'db_librato_display_units_long', 'db_librato_display_units_short', 'db_librato_display_stacked', 'db_librato_display_transform', 'db_librato_max', 'db_librato_min', 'db_librato_measure_time', 'db_librato_period', 'db_librato_source', 'db_librato_sum', 'db_librato_summarize_function', 'db_librato_sum_squares', 'db_librato_type') as $param) {
                     if (isset($this->options[$param]) && count($this->options[$param]) != count($this->options[$valueCol]) && count($this->options[$param]) != 1) {
                         $this->valid = FALSE;
                         print_msg(sprintf('--%s can only be set once or %d times (once for each --%s)', $param, count($this->options[$valueCol]), $valueCol), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                     }
                 }
             }
         }
         if ($this->valid) {
             // validate credentials using GET request
             $curl = ch_curl(self::LIBRATO_METRICS_API_URL, 'GET', NULL, NULL, sprintf('%s:%s', $this->options['db_user'], $this->options['db_pswd']), '200-299', TRUE);
             $this->valid = ($response = json_decode($curl, TRUE)) ? TRUE : FALSE;
             if ($curl === NULL) {
                 print_msg(sprintf('Librato API GET request to %s failed', self::LIBRATO_METRICS_API_URL), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             } else {
                 if ($curl === FALSE) {
                     print_msg(sprintf('Librato API GET request to %s resulted in non 200 response code - API credentials may be invalid', self::LIBRATO_METRICS_API_URL), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                 } else {
                     if ($curl && !$response) {
                         print_msg(sprintf('Librato API GET request to %s successful, but body did not contain valid JSON', self::LIBRATO_METRICS_API_URL), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                     } else {
                         print_msg(sprintf('Librato API GET request to %s successful. There are %d existing metrics', self::LIBRATO_METRICS_API_URL, count($response['metrics'])), isset($this->options['verbose']), __FILE__, __LINE__);
                     }
                 }
             }
         }
     }
     return $this->valid;
 }
function meusdados_entries()
{
    $name = FrontUser::name();
    $theme_opts = get_option('marisa_options');
    $site_url = site_url();
    $change_passord = FrontUser::uid() ? '' : <<<HTML
        <p class='bold'>Alterar Senha</p>
        <label for="senhaatual">Senha atual: <input id="senha_atual" name="senha_atual" type="password" class="half" /></label>
        <label for="senha">Nova senha: <input id="senha" name="user_senha" type="password" class="half" /></label>
        <label for="repetirsenha">Repita a senha: <input id="repetirsenha" name="repetirsenha" type="password" class="half" /></label>
HTML;
    $html = "";
    $html .= "<p>" . $theme_opts['marisa_cadastrese_descricao'] . "</p>";
    $html .= "<div class='col1'>";
    $html .= print_msg();
    $html .= <<<HTML
    <form id="signup-form" class="edit-info-form" name="cadastro" action="" method="post"/>
        <label for="name">Nome: <input name="user_name" value="{$name}" type="text" required/></label>

        {$change_passord}

        <input name="update_info" type="hidden" value="1"/>

        <button type="submit"><ico class="sprite-cadastrese"></ico>SALVAR ALTERAÇÕES</button>
        <a class="button" href="{$site_url}/?front_user_logout=true"><ico class="sprite-logoff"></ico>FAZER LOGOFF</a>
    </form>
</div>
<div class='col2'>
HTML;
    if (isset($theme_opts[marisa_call_sign_fd]) && strlen($theme_opts[marisa_call_sign_fd]) > 0) {
        $html .= "<img src='" . $theme_opts[marisa_call_sign_fd] . "' title=''/>";
    }
    $html .= "</div>";
    return $html;
}
Beispiel #10
0
 $table2_attr = array();
 $table1_attr["id"] = "id";
 $table1_attr["num"] = "num1";
 $table2_attr["num"] = "num2";
 $join_attr["id"] = "id";
 $sub_query_1 = mysql_join_str($join_attr, $table1, $table1_attr, $table2, $table2_attr, "LEFT");
 $table1_attr = array();
 $table2_attr = array();
 $table1_attr["num"] = "num1";
 $table2_attr["id"] = "id";
 $table2_attr["num"] = "num2";
 $join_attr["id"] = "id";
 $sub_query_2 = mysql_join_str($join_attr, $table1, $table1_attr, $table2, $table2_attr, "RIGHT");
 $sub_query = "{$sub_query_1} UNION {$sub_query_2}";
 #$sub_query = "SELECT Deck_mage_1.id AS id, Deck_mage_1.num AS num1, Deck_mage_2.num AS num2 FROM Deck_mage_1 LEFT JOIN Deck_mage_2 ON Deck_mage_1.id = Deck_mage_2.id UNION SELECT Deck_mage_2.id AS id, Deck_mage_1.num AS num1, Deck_mage_2.num AS num2 FROM Deck_mage_1 RIGHT JOIN Deck_mage_2 ON Deck_mage_1.id = Deck_mage_2.id";
 print_msg($sub_query);
 $show_attr = array("num1", "num2");
 $show_attr = array_merge($show_attr, $CARD_TABLE_SHOW_ATTR);
 $show_str = implode(', ', $show_attr);
 #$show_str = implode(', ', $CARD_TABLE_SHOW_ATTR);
 #$sub_query = "SELECT $table1.id AS id, $table1.num AS num1, $table2.num AS num2 FROM $table1 INNER JOIN $table2 ON $table1.id = $table2.id";
 $query = "SELECT {$show_str} FROM {$CARD_TABLE_NAME} INNER JOIN ({$sub_query}) sub ON {$CARD_TABLE_NAME}.id = sub.id;";
 #$query = "SELECT * FROM $table1 NATURAL JOIN SELECT * FROM $table2;";
 #print_msg($sub_query);
 #print_msg($query);
 $result = mysql_query($query);
 #print_relation($result, array("id", "num"));
 #print_relation($result, $CARD_TABLE_SHOW_ATTR);
 print_relation($result, $show_attr);
 #$query = "SELECT * FROM $table1 WHERE id NOT IN (SELECT id FROM $table2);";
 #echo $query;
 /**
  * validation method - may be overriden by sub-classes, but parent method 
  * should still be invoked. returns TRUE if db options are valid, FALSE 
  * otherwise
  * @return boolean
  */
 protected function validate()
 {
     if ($valid = parent::validate()) {
         if (isset($this->options['db_host'])) {
             if ($valid = ch_curl($this->getUrl(), 'HEAD', $this->getHeaders(), NULL, $this->getAuth())) {
                 print_msg('Successfully validated callback using HEAD request', isset($this->options['verbose']), __FILE__, __LINE__);
             } else {
                 print_msg('Unable to validate callback using HEAD request', isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             }
         } else {
             $valid = FALSE;
             print_msg('--db_host argument is required for --db callback', isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
         }
     }
     return $valid;
 }
 /**
  * validation method - must be implemented by subclasses. Returns TRUE if 
  * archiver options are valid, FALSE otherwise
  * @return boolean
  */
 protected function validate()
 {
     if ($valid = isset($this->options['store_key']) && isset($this->options['store_secret']) && isset($this->options['store_container'])) {
         $valid = FALSE;
         print_msg(sprintf('Validating GCS connection using --store_key %s, --store_container %s', $this->options['store_key'], $this->options['store_container']), isset($this->options['verbose']), __FILE__, __LINE__);
         $curl = ch_curl($this->getUrl(), 'HEAD', $this->getHeaders(), NULL, NULL, '200,404');
         if ($curl === 200) {
             $valid = TRUE;
             print_msg(sprintf('GCS authentication and bucket validation successful'), __FILE__, __LINE__);
         } else {
             if ($curl === 404) {
                 print_msg(sprintf('GCS authentication successful but bucket %s does not exist', $this->options['store_container']), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             } else {
                 print_msg(sprintf('GCS authentication failed'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
             }
         }
     } else {
         print_msg(sprintf('--store_key, --store_secret and --store_container are required'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
     }
     return $valid;
 }
Beispiel #13
0
/**
 * merges config options into $options
 * @param array $options the options to merge into
 * @param string $config the config file to merge with
 * @return void
 */
function merge_options_with_config(&$options, $config)
{
    foreach (explode("\n", shell_exec('cat ' . $config . ' 2>/dev/null')) as $line) {
        if (substr(trim($line), 0, 1) == '#') {
            continue;
        }
        if (preg_match('/([A-Za-z_]+)\\s*=?\\s*(.*)$/', $line, $m) && !isset($options[$key = strtolower($m[1])])) {
            print_msg(sprintf('Added option %s=%s from config %s', $key, preg_match('/pswd/', $key) || preg_match('/key/', $key) ? '***' : $m[2], $config), isset($options['verbose']), __FILE__, __LINE__);
            $options[$key] = $m[2] ? trim($m[2]) : TRUE;
        }
    }
}
 /**
  * Performs workload dependent preconditioning - this method must be 
  * implemented by sub-classes. It should return one of the following 
  * values:
  *   TRUE:  preconditioning successful and steady state achieved
  *   FALSE: preconditioning successful but steady state not achieved
  *   NULL:  preconditioning failed
  * @return boolean
  */
 public function wdpc()
 {
     $status = NULL;
     if ($this->bs !== NULL) {
         $bs = $this->bs;
         $status = NULL;
         if ($this->purgeAndPrecondition) {
             print_msg(sprintf('Repeating purge and workload independent preconditioning'), $this->verbose, __FILE__, __LINE__);
             $this->purge();
             $this->wipc($bs);
         }
         print_msg(sprintf('Initiating %s workload dependent preconditioning and steady state for THROUGHPUT test', $this->bs), $this->verbose, __FILE__, __LINE__);
         $max = $this->options['ss_max_rounds'];
         $workloads = $this->filterWorkloads(array('100/0', '0/100'));
         $ssMetrics = array();
         for ($x = 1; $x <= $max; $x++) {
             foreach ($workloads as $rw) {
                 $name = sprintf('x%d-%s-%s-seq', $x, str_replace('/', '_', $rw), $bs);
                 print_msg(sprintf('Executing sequential THROUGHPUT test iteration for round %d of %d, workload %s and block size %s', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__);
                 if ($fio = $this->fio(array('blocksize' => $bs, 'name' => $name, 'runtime' => $this->options['wd_test_duration'], 'rw' => $rw == '100/0' ? 'read' : 'write', 'time_based' => FALSE), 'wdpc')) {
                     print_msg(sprintf('Sequential THROUGHPUT test iteration for round %d of %d, workload %s and block size %s was successful', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__);
                     $results = $this->fio['wdpc'][count($this->fio['wdpc']) - 1];
                 } else {
                     print_msg(sprintf('Random IO test iteration for round %d of %d, rw ratio %s and block size %s failed', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__, TRUE);
                     break;
                 }
                 if ($rw == '0/100') {
                     $bw = round($results['jobs'][0]['write']['bw'] / 1024, 2);
                     print_msg(sprintf('Added BW metric %s MB/s for steady state verification', $bw), $this->verbose, __FILE__, __LINE__);
                     $ssMetrics[$x] = $bw;
                     // check for steady state
                     if ($x >= 5) {
                         $metrics = array();
                         for ($i = 4; $i >= 0; $i--) {
                             $metrics[$x - $i] = $ssMetrics[$x - $i];
                         }
                         print_msg(sprintf('Test iteration for round %d of %d complete and >= 5 rounds finished - checking if steady state has been achieved using %s THROUGHPUT metrics [%s],[%s]', $x, $max, count($metrics), implode(',', array_keys($metrics)), implode(',', $metrics)), $this->verbose, __FILE__, __LINE__);
                         if ($this->isSteadyState($metrics, $x)) {
                             print_msg(sprintf('Steady state achieved - %s testing will stop', $bs), $this->verbose, __FILE__, __LINE__);
                             $status = TRUE;
                         } else {
                             print_msg(sprintf('Steady state NOT achieved'), $this->verbose, __FILE__, __LINE__);
                         }
                         // end of the line => last test round and steady state not achieved
                         if ($x == $max && $status === NULL) {
                             $status = FALSE;
                         }
                     }
                 }
                 if (!$fio || $status !== NULL) {
                     break;
                 }
             }
             if (!$fio || $status !== NULL) {
                 break;
             }
         }
         // set wdpc attributes
         $this->wdpc = $status;
         $this->wdpcComplete = $x;
         $this->wdpcIntervals = count($workloads);
     } else {
         foreach (array_keys($this->subtests) as $i => $bs) {
             print_msg(sprintf('Starting workload dependent preconditioning for throughput block size %s (%d of %d)', $bs, $i + 1, count($this->subtests)), $this->verbose, __FILE__, __LINE__);
             $status = $this->subtests[$bs]->wdpc();
             foreach (array_keys($this->subtests[$bs]->fio) as $step) {
                 if (!isset($this->fio[$step])) {
                     $this->fio[$step] = array();
                 }
                 foreach ($this->subtests[$bs]->fio as $job) {
                     $this->fio[$step][] = $job;
                 }
             }
             if ($status === NULL) {
                 break;
             }
         }
     }
     return $status;
 }
 /**
  * validates dependencies for the chosen benchmark db. returns TRUE if 
  * present, FALSE otherwise
  * @return boolean
  */
 private final function validateDependencies()
 {
     $dependencies = array();
     if (isset($this->options['db'])) {
         switch ($this->options['db']) {
             case 'bigquery':
                 $dependencies['bq'] = 'Google Cloud SDK';
                 break;
             case 'callback':
             case 'librato':
                 $dependencies['curl'] = 'curl';
                 break;
             case 'mysql':
                 $dependencies['mysql'] = 'mysql';
                 break;
             case 'postgresql':
                 $dependencies['psql'] = 'postgresql';
                 break;
             default:
                 $err = '--db ' . $options['db'] . ' is not valid';
                 break;
         }
     }
     if ($this->archiver) {
         $dependencies['curl'] = 'curl';
     }
     if ($dependencies = validate_dependencies($dependencies)) {
         foreach ($dependencies as $dependency) {
             print_msg(sprintf('Missing dependence %s', $dependency), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
         }
     }
     return count($dependencies) > 0 ? FALSE : TRUE;
 }
Beispiel #16
0
                }
            }
            foreach (array_keys($results) as $n) {
                $results[$n]['iteration'] = $iteration;
                if ($db->addRow('network', $results[$n])) {
                    print_msg(sprintf('Successfully added test result row'), $verbose, __FILE__, __LINE__);
                } else {
                    print_msg(sprintf('Failed to save test results'), $verbose, __FILE__, __LINE__, TRUE);
                }
            }
        } else {
            print_msg(sprintf('Unable to save results in directory %s - are result files present?', $dir), $verbose, __FILE__, __LINE__, TRUE);
        }
    }
    // finalize saving of results
    if ($db->save()) {
        print_msg(sprintf('Successfully saved test results from directory %s', $dir), $verbose, __FILE__, __LINE__);
        $status = 0;
    } else {
        print_msg(sprintf('Unable to save test results from directory %s', $dir), $verbose, __FILE__, __LINE__, TRUE);
        $status = 1;
    }
    // check for --min_runtime test option
    if ((!isset($args['recursive_order']) || isset($args['recursive_count']) && $args['recursive_order'] == $args['recursive_count']) && isset($runOptions['min_runtime']) && isset($runOptions['min_runtime_in_save']) && is_numeric($runOptions['min_runtime']) && isset($runOptions['run_start']) && is_numeric($runOptions['run_start']) && time() < $runOptions['run_start'] + $runOptions['min_runtime']) {
        $sleep = $runOptions['run_start'] + $runOptions['min_runtime'] - time();
        print_msg(sprintf('Testing complete and --min_runtime %d has not been acheived. Sleeping for %d seconds', $runOptions['min_runtime'], $sleep), $verbose, __FILE__, __LINE__);
        sleep($sleep);
        print_msg(sprintf('Sleep complete'), $verbose, __FILE__, __LINE__);
    }
}
exit($status);
Beispiel #17
0
function phpErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
    global $common_contactEmail;
    if (error_reporting() == 0) {
        return;
    }
    // define an assoc array of error string
    // in reality the only entries we should
    // consider are 2,8,256,512 and 1024
    $handleErrors = array(1 => "Error", 2 => "Warning", 4 => "Parsing Error", 16 => "Core Error", 32 => "Core Warning", 64 => "Compile Error", 128 => "Compile Warning", 256 => "User Error", 512 => "User Warning", 1024 => "User Notice");
    $backtraceErrors = array();
    $emailErrors = array();
    $logErrors = array();
    $dieErrors = array(4, 16, 64);
    if (!isset($handleErrors[$errno])) {
        return;
    }
    // set of errors for which a var trace will be saved
    $dt = date("Y-m-d H:i:s (T)");
    $err = "When: {$dt}<br>\n           Script: {$filename}:{$linenum}<br>\n           Message: {$errmsg}";
    if ($common_contactEmail && in_array($errno, $emailErrors)) {
        $email = $err . '\\n\\n';
        foreach ($vars as $key => $value) {
            $email .= "Parameter: {$key}\nvalue: {$value}\n\n";
        }
        mail($common_contactEmail, "Error: http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}", "Error #{$errno}: {$handleErrors[$errno]}\n\n{$email}");
    }
    if (in_array($errno, $backtraceErrors)) {
        $err .= "<p><table border=0>";
        foreach ($vars as $key => $value) {
            $err .= "<tr><td style=\"border-top: 1px black solid;\">parameter: {$key}<br>value: {$value}</td></tr>";
        }
        $err .= '</table>';
    }
    print_msg('error', sprintf(_("Error #%u: %s"), $errno, $handleErrors[$errno]), $err);
    // save to the error log, and e-mail me if there is a critical user error
    if (ini_get('error_log') && in_array($errno, $logErrors)) {
        error_log($err, 3, ini_get('error_log'));
    }
    if (in_array($errno, $dieErrors)) {
        die;
    }
}
 /**
  * Performs workload dependent preconditioning - this method must be 
  * implemented by sub-classes. It should return one of the following 
  * values:
  *   TRUE:  preconditioning successful and steady state achieved
  *   FALSE: preconditioning successful but steady state not achieved
  *   NULL:  preconditioning failed
  * @return boolean
  */
 public function wdpc()
 {
     $status = NULL;
     print_msg(sprintf('Initiating workload dependent preconditioning and steady state for WSAT test'), $this->verbose, __FILE__, __LINE__);
     $max = $this->options['ss_max_rounds'];
     $ssMetrics = array();
     $tgbw = 0;
     for ($x = 1; $x <= $max; $x++) {
         for ($n = 1; $n <= BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_PRECONDITION_INTERVALS; $n++) {
             $name = sprintf('x%d-0_100-4k-rand-n%d', $x, $n);
             print_msg(sprintf('Starting %d sec HIR 4k rand write preconditioning round %d of %d, test %d of %d [name=%s]', $this->options['wd_test_duration'], $x, $max, $n, BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_PRECONDITION_INTERVALS, $name), $this->verbose, __FILE__, __LINE__);
             $params = array('blocksize' => '4k', 'name' => $name, 'runtime' => $this->options['wd_test_duration'], 'rw' => 'randwrite', 'time_based' => FALSE);
             if ($fio = $this->fio($params, 'wdpc')) {
                 print_msg(sprintf('Test %s was successful', $name), $this->verbose, __FILE__, __LINE__);
                 $results = $this->fio['wdpc'][count($this->fio['wdpc']) - 1];
             } else {
                 print_msg(sprintf('Test %s failed', $name), $this->verbose, __FILE__, __LINE__, TRUE);
                 break;
             }
         }
         // add steady state metric
         if ($results) {
             $iops = $results['jobs'][0]['write']['iops'];
             print_msg(sprintf('Added IOPS metric %d from preconditioning round %d of %d for HIR steady state verification', $iops, $x, $max), $this->verbose, __FILE__, __LINE__);
             $ssMetrics[$x] = $iops;
             // check for steady state at rounds 5+
             if ($x >= 5) {
                 $metrics = array();
                 for ($i = 4; $i >= 0; $i--) {
                     $metrics[$x - $i] = $ssMetrics[$x - $i];
                 }
                 print_msg(sprintf('HIR preconditioning test %d of %d complete and >= 5 rounds finished - checking if steady state has been achieved using 4k write IOPS metrics [%s],[%s]', $x, $max, implode(',', array_keys($metrics)), implode(',', $metrics)), $this->verbose, __FILE__, __LINE__);
                 if ($this->isSteadyState($metrics, $x)) {
                     print_msg(sprintf('HIR steady state achieved - testing will stop'), $this->verbose, __FILE__, __LINE__);
                     $status = TRUE;
                 } else {
                     print_msg(sprintf('HIR steady state NOT achieved'), $this->verbose, __FILE__, __LINE__);
                 }
                 // end of the line => last test round and steady state not achieved
                 if ($x == $max && $status === NULL) {
                     $status = FALSE;
                 }
             }
         }
         if (!$results || $status !== NULL) {
             break;
         }
     }
     $this->wdpcComplete = $x;
     $this->wdpcIntervals = BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_PRECONDITION_INTERVALS;
     // wait state segments
     if ($status !== NULL) {
         print_msg(sprintf('HIR preconditioning complete - beginning wait state test segments'), $this->verbose, __FILE__, __LINE__);
         foreach (array(5, 10, 15, 25, 50) as $wait) {
             for ($x = 1; $x <= BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_SIZE; $x++) {
                 $name = sprintf('w%d-0_100-4k-rand-%d', $x, $wait);
                 print_msg(sprintf('Starting %d sec HIR 4k rand write wait segment %d of %d [name=%s; wait=%dsec]', BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_DURATION, $x, BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_SIZE, $name, $wait), $this->verbose, __FILE__, __LINE__);
                 $params = array('blocksize' => '4k', 'name' => $name, 'runtime' => BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_DURATION, 'rw' => 'randwrite', 'time_based' => FALSE);
                 if ($fio = $this->fio($params, 'wdpc')) {
                     print_msg(sprintf('Test %s was successful - sleeping for %d seconds', $name, $wait), $this->verbose, __FILE__, __LINE__);
                     sleep($wait);
                 } else {
                     print_msg(sprintf('Test %s failed', $name), $this->verbose, __FILE__, __LINE__, TRUE);
                     break;
                 }
             }
             if (!$fio) {
                 break;
             }
             // return to baseline using 1800 seconds of continuous 4k writes
             for ($x = 1; $x <= BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_SIZE; $x++) {
                 $name = sprintf('x%d-baseline-0_100-4k-rand-%d', $x, $wait);
                 $params = array('blocksize' => '4k', 'name' => $name, 'runtime' => BlockStorageTestHir::BLOCK_STORAGE_TEST_HIR_WAIT_LOOP_DURATION, 'rw' => 'randwrite', 'time_based' => FALSE);
                 if ($fio = $this->fio($params, 'wdpc')) {
                     print_msg(sprintf('Test %s was successful - sleeping for %d seconds', $name, $wait), $this->verbose, __FILE__, __LINE__);
                     sleep($wait);
                 } else {
                     print_msg(sprintf('Test %s failed', $name), $this->verbose, __FILE__, __LINE__, TRUE);
                     break;
                 }
             }
         }
     }
     // set wdpc attributes
     $this->wdpc = $status;
     return $status;
 }
 /**
  * Performs workload dependent preconditioning - this method must be 
  * implemented by sub-classes. It should return one of the following 
  * values:
  *   TRUE:  preconditioning successful and steady state achieved
  *   FALSE: preconditioning successful but steady state not achieved
  *   NULL:  preconditioning failed
  * @return boolean
  */
 public function wdpc()
 {
     $status = NULL;
     print_msg(sprintf('Initiating workload dependent preconditioning and steady state for WSAT test'), $this->verbose, __FILE__, __LINE__);
     $max = $this->options['ss_max_rounds'];
     $ssMetrics = array();
     $tgbw = 0;
     for ($x = 1; $x <= $max; $x++) {
         // perform 31 4k 100% rand write test intervals - use the last for steady
         // state confirmation
         for ($n = 1; $n <= BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_CYCLES; $n++) {
             $testNum = ($x - 1) * BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_CYCLES + $n;
             $name = sprintf('x%d-0_100-4k-rand-%d', $x, $testNum);
             print_msg(sprintf('Starting %dsec 4k rand write test %d of %d [%d] for WSAT test iteration %d of %d [name=%s]. TGBW=%s GB', $this->options['wd_test_duration'], $n, BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_CYCLES, $testNum, $x, $max, $name, round($tgbw, BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_ROUND_PRECISION)), $this->verbose, __FILE__, __LINE__);
             $params = array('blocksize' => '4k', 'name' => $name, 'runtime' => $this->options['wd_test_duration'], 'rw' => 'randwrite', 'time_based' => FALSE);
             if ($fio = $this->fio($params, 'wdpc')) {
                 print_msg(sprintf('Test %s was successful', $name), $this->verbose, __FILE__, __LINE__);
                 $results = $this->fio['wdpc'][count($this->fio['wdpc']) - 1];
                 $tgbw += $results['jobs'][0]['write']['io_bytes'] / 1024 / 1024;
             } else {
                 print_msg(sprintf('Test %s failed', $name), $this->verbose, __FILE__, __LINE__, TRUE);
                 break;
             }
             // add steady state metric
             if ($n == BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_CYCLES) {
                 $iops = $results['jobs'][0]['write']['iops'];
                 print_msg(sprintf('Added IOPS metric %d for WSAT steady state verification', $iops), $this->verbose, __FILE__, __LINE__);
                 $ssMetrics[$x] = $iops;
                 // check for steady state at rounds 5+
                 if ($x >= 5) {
                     $metrics = array();
                     for ($i = 4; $i >= 0; $i--) {
                         $metrics[$x - $i] = $ssMetrics[$x - $i];
                     }
                     print_msg(sprintf('WSAT test round %d of %d complete and >= 5 rounds finished - checking if steady state has been achieved using 4k write IOPS metrics [%s],[%s]', $x, $max, implode(',', array_keys($metrics)), implode(',', $metrics)), $this->verbose, __FILE__, __LINE__);
                     if ($this->isSteadyState($metrics, $x)) {
                         print_msg(sprintf('WSAT steady state achieved - testing will stop'), $this->verbose, __FILE__, __LINE__);
                         $status = TRUE;
                     } else {
                         print_msg(sprintf('WSAT steady state NOT achieved'), $this->verbose, __FILE__, __LINE__);
                     }
                     // end of the line => last test round and steady state not achieved
                     if ($x == $max && $status === NULL) {
                         $status = FALSE;
                     }
                 }
             }
             if (!$fio || $status !== NULL) {
                 break;
             }
         }
         if (!$fio || $status !== NULL) {
             break;
         }
     }
     // set wdpc attributes
     $this->wdpc = $status;
     $this->wdpcComplete = $x;
     $this->wdpcIntervals = BlockStorageTestWsat::BLOCK_STORAGE_TEST_WSAT_CYCLES;
     return $status;
 }
Beispiel #20
0
include "../db/login.php";
include "mysql_query.php";
include "html.php";
#include "util.php";
include "global.php";
$link = @mysql_connect("{$servername}", "{$username}", "{$password}");
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die("Unable to select database");
if (array_key_exists("id", $_GET)) {
    $id = $_GET["id"];
    $table = get_deck_table_name($id);
    if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$table}'")) == 1) {
        echo "<aside>";
        print_msg($id);
        $total = print_table($table, $DECK_SINGLE_TABLE_ATTR);
        print_msg("total = {$total}");
        echo "</aside>";
    }
}
$total = print_table($DECK_TABLE_NAME, $DECK_TABLE_ATTR, 'print_deck_table_callback');
print_msg("total = {$total}");
# close
mysql_close($link);
?>

</body>
</html>

Beispiel #21
0
function delete_class_files($dir)
{
    global $verbose;
    $all_files = scandir($dir);
    foreach ($all_files as $f) {
        if (preg_match('#\\.class\\.php$#i', $f) || preg_match('#\\.map\\.inc\\.php$#i', $f)) {
            if (unlink("{$dir}/{$f}")) {
                if ($verbose) {
                    print_msg(sprintf('<br/>Deleted file: <code>%s/%s</code>', $dir, $f));
                }
            } else {
                print_msg(sprintf('<br/>Failed to delete file: <code>%s/%s</code>', $dir, $f));
            }
        }
    }
}
Beispiel #22
0
function generate_tablature()
{
    print_msg("<font color=blue>GENERATING TABLATURE</font>");
    global $spartiti_dir;
    global $cfg_dir;
    if (file_exists("{$cfg_dir}/tablature.cfg") == false) {
        echo "Missing CFG file, skipping.<br>";
        return;
    }
    global $contents_dir;
    $file_name = "{$cfg_dir}/tablature.cfg";
    $fin = fopen($file_name, "r");
    if (!$fin) {
        print_msg("Unable to open '{$file_name}' in generate_tablature()");
        return false;
    }
    $author = null;
    $album = null;
    $track = null;
    $year = null;
    $fout = null;
    $filename = null;
    $artist_list = null;
    $track_num = 0;
    $linenum = 0;
    $artistcount = 0;
    $songcount = 0;
    while (true) {
        $linenum++;
        $line = fgets($fin);
        global $base_website_address;
        if (feof($fin)) {
            if ($fout != null) {
                fwrite($fout, "<h2><a href=\"http://<?php echo \"\$base_website_address/\$spartiti_dir\" ?" . ">/index.html\" title=\"Trova accordi, spartiti, tablature e testi di tantissimi artisti\">Torna all'indice degli artisti</a></h2>\n");
                fclose($fout);
            }
            break;
        }
        $line = trim($line);
        if (strlen($line) == 0) {
            continue;
        }
        if ($line[0] == '#') {
            continue;
        }
        $divider_pos = strpos($line, ":");
        $tag = substr($line, 0, $divider_pos);
        $value = substr($line, $divider_pos + 1);
        $tag = trim($tag);
        $value = trim($value);
        if ($value == "") {
            echo "ERROR: no value at line {$linenum}<br>";
            return;
        }
        // echo "$tag == $value<br>";
        switch (strtolower($tag)) {
            case "artist":
                $artistcount++;
                $author = $value;
                // reset variables
                $album = null;
                $track = null;
                $year = null;
                // close previous artist
                if ($fout != null) {
                    fwrite($fout, "<h2><a href=\"http://<?php echo \"\$base_website_address/\$spartiti_dir\" ?" . ">/index.html\" title=\"Trova accordi, spartiti, tablature e testi di tantissimi artisti\">Torna all'indice degli artisti</a></h2>\n");
                    fclose($fout);
                }
                // creates filename for this artist
                $filename = "spartiti-chitarra-testi-accordi-" . strtolower(transform_str_in_filename($value));
                // compiles the list for the index
                $artist_list[$value] = $filename;
                // opens the file for this artist
                $fout = fopen($contents_dir . "/{$spartiti_dir}/" . $filename . ".php", "w");
                // write header
                fwrite($fout, "<!--\n");
                fwrite($fout, "title: Discografia {$author}. Spartiti, accordi, testi e tablature di {$author}\n");
                fwrite($fout, "description: Discografia {$author}. Trova tutti gli spartiti, accordi, testi e tablature di {$author}\n");
                fwrite($fout, "keywords: Discografia, {$author}, spartiti, accordi, testi, tablature\n");
                fwrite($fout, "template: tablature\n");
                fwrite($fout, "-->\n");
                fwrite($fout, "<h1>Discografia {$author}</h1><h2>Trova spartiti, accordi, testi e tablature</h2>\n");
                fwrite($fout, "<?php require(\"tabdescription.php\"); ?" . ">\n");
                fwrite($fout, "<?php require(\"adsense_leaderboard.php\"); ?" . ">\n");
                break;
            case "album":
                $track_num = 1;
                fwrite($fout, "<h2>{$value} ");
                if ($year != null) {
                    fwrite($fout, "({$year})");
                }
                fwrite($fout, "</h2>\n");
                $album = $value;
                break;
            case "year":
                $year = $value;
                break;
            case "track":
                $songcount++;
                $url_track = urlencode($value);
                $ulr_author = urlencode($author);
                fwrite($fout, "<b>{$track_num}</b>. {$value} - ");
                fwrite($fout, "<a target=\"_blank\" href=\"http://www.google.com/search?q=spartiti+{$url_track}+{$ulr_author}\" title=\"Spartiti di {$value}\">spartiti</a>");
                fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=accordi+{$url_track}+{$ulr_author}\" title=\"Accordi di {$value}\">accordi</a>");
                fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=testi+{$url_track}+{$ulr_author}\" title=\"Testi di {$value}\">testi</a>");
                // fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=tablature+$url_track+$ulr_author\" title=\"cerca tablature di '$value'\">tablature</a>");
                // fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=lyrics+$url_track+$ulr_author\" title=\"cerca lyrics di '$value'\">lyrics</a>");
                // fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=chords+$url_track+$ulr_author\" title=\"cerca chords di '$value'\">chords</a>");
                // fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=tabs+$url_track+$ulr_author\" title=\"cerca tabs di '$value'\">tabs</a>");
                // fwrite($fout, ", <a target=\"_blank\" href=\"http://www.google.com/search?q=powertabs+$url_track+$ulr_author\" title=\"cerca powertabs di '$value'\">powertabs</a>");
                fwrite($fout, "<br>\n");
                $track_num++;
                break;
            default:
                echo "ERROR: unknown tag '{$tag}' at line {$linenum}<br>\n";
                return false;
                break;
        }
    }
    fclose($fin);
    // alphabetical sort by artists
    ksort($artist_list);
    // generate index
    /* $fout = fopen($contents_dir."/$spartiti_dir/index.php", "w");
       fwrite($fout, "<!--\n");
       fwrite($fout, "title: Trova discografie, spartiti, accordi, testi e tablature di artisti italiani e stranieri\n");
       fwrite($fout, "description: Trova discografie, spartiti, accordi, testi e tablature di artisti italiani e stranieri.\n");
       fwrite($fout, "keywords: Discografia, spartiti, accordi, testi, tablature\n");
       fwrite($fout, "template: default\n");
       fwrite($fout, "-->\n");
       fwrite($fout, "<center><h1>Trova discografie, spartiti, accordi, testi e tablature di $artistcount artisti italiani e stranieri e $songcount canzoni!</h1></center>\n");
       
       fwrite($fout, "<p>Quante volte ci e' capitato di cercare uno spartito, un testo o gli accordi di una canzone, o di voler conoscere la discografia di un artista?
       Sicuramente tantissime! Questo servizo di permette di utilizzare al meglio la potenza di Google in modo semplice ed intuitivo per trovare i migliori spartiti, accordi e testi delle tue canzoni preferite.
       Clicca sul nome di un artista per vedere la sua discografia, ti si presentera' la lista delle relative canzoni divise per album con accanto dei pratici link
       che ti porteranno dritto alle fonti piu' accreditate da cui reperire i migliori spartiti, accordi, testi e tablature che ti interessano.
       Spesso per trovare
       degli spartiti o accordi di adeguata qualita' e' necessario verificare piu' fonti, per cui e' preferibile controllare almeno due o tre versioni della stessa canzone da siti diversi.\n
       Nel database sono presenti ben $songcount canzoni di $artistcount artisti!</p>
       <p>Buona ricerca!</p>\n");
       
       fwrite($fout, "<?php require(\"tabgrid.php\"); ?".">\n");
       fclose($fout); */
    $count = 0;
    $col = 1;
    $incol = 0;
    $fout = fopen($contents_dir . "/{$spartiti_dir}/tabgrid.php", "w");
    fwrite($fout, "<table class=\"tabindex\" border=0><tr><td valign=top>\n");
    foreach ($artist_list as $artist => $file) {
        $count++;
        $incol++;
        fwrite($fout, "<b>{$count}.</b> <a href=\"http://<?php echo \"\$base_website_address/\$spartiti_dir\" ?" . ">/{$file}.html\" title=\"Trova accordi, spartiti, tablature e testi di {$artist}\">{$artist}</a><br />\n");
        if ($incol == 10) {
            $incol = 0;
            $col++;
            fwrite($fout, "</td>\n");
            if ($col == 5) {
                fwrite($fout, "</tr><tr>\n");
                $col = 1;
            }
            fwrite($fout, "<td valign=top>\n");
        }
    }
    for ($i = 0; $i < 4 - $col; $i++) {
        fwrite($fout, "</td><td>&nbsp;\n");
    }
    fwrite($fout, "</td>\n");
    fwrite($fout, "</tr></table>\n");
    fclose($fout);
}
 /**
  * validation method - may be overriden by sub-classes, but parent method 
  * should still be invoked. returns TRUE if db options are valid, FALSE 
  * otherwise
  * @return boolean
  */
 protected function validate()
 {
     if ($valid = parent::validate()) {
         $table = 'test_' . $this->getTableName(rand());
         if ($this->mysql(sprintf('CREATE TABLE %s (id int)%s', $table, isset($this->options['db_mysql_engine']) ? ' ENGINE=' . $this->options['db_mysql_engine'] : '')) !== NULL) {
             // try to load some data into the table
             $fp = fopen($tmp = '/tmp/' . $table, 'w');
             fwrite($fp, rand() . "\n" . rand());
             fclose($fp);
             $query = sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE %s", $tmp, $table);
             $imported = $this->mysql($query);
             unlink($tmp);
             $this->mysql('drop table ' . $table);
             $dropped = $this->mysql('desc ' . $table);
             if ($dropped !== NULL) {
                 print_msg(sprintf('Unable to drop test table %s - check that user has DROP TABLE permissions', $table), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                 $valid = FALSE;
             } else {
                 if ($imported !== NULL) {
                     print_msg(sprintf('Validated MySQL connection by creating and importing data to a temporary table %s - table has been removed', $table), isset($this->options['verbose']), __FILE__, __LINE__);
                 } else {
                     $valid = FALSE;
                     print_msg(sprintf('MySQL connection successful, but unable to import data using LOAD DATA LOCAL INFILE. Check these permissions for this user'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
                 }
             }
         } else {
             $valid = FALSE;
             print_msg(sprintf('MySQL connection failed - %s', $this->mysql() !== NULL ? 'user cannot create tables' : 'unable to connect to server'), isset($this->options['verbose']), __FILE__, __LINE__, TRUE);
         }
     }
     return $valid;
 }
Beispiel #24
0
$link = @mysql_connect("{$servername}", "{$username}", "{$password}");
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die("Unable to select database");
# decode json
$file_name = "../data/AllSets.json";
$json_str = read_file($file_name);
$json_arr = json_decode($json_str);
#dump_attributes($json_arr);
# rebuild data
drop_table($CARD_TABLE_NAME);
create_table($CARD_TABLE_NAME);
insert_card_data($CARD_TABLE_NAME, $json_arr);
# msg
print_msg("reset {$CARD_TABLE_NAME}");
# close
mysql_close($link);
?>

<?php 
#------------------------------------------------------------------------------
#   build data
#------------------------------------------------------------------------------
function insert_card_data($table, $arr)
{
    foreach ($arr as $set_type => $card_obj) {
        $card_array = (array) $card_obj;
        foreach ($card_array as $set_seq => $card_info_obj) {
            $data = array();
            $data["setType"] = $set_type;
Beispiel #25
0
            if (!$controller->wipc()) {
                $exitCode = 1;
                print_msg(sprintf('Testing aborted because workload independent preconditioning failed and --noprecondition argument was not specified'), $verbose, __FILE__, __LINE__, TRUE);
                break;
            } else {
                print_msg(sprintf('Workload independent preconditioning successful - continuing testing'), $verbose, __FILE__, __LINE__);
            }
        }
        // workload dependent pre-conditioning & testing
        $status = $controller->wdpc();
        if ($status !== NULL) {
            print_msg(sprintf('Workload dependent preconditioning for test %s successful%s. wdpcComplete=%d; wdpcIntervals=%d. Generating test artifacts...', $test, $status ? '' : ' - but steady state was not achieved', $controller->wdpcComplete, $controller->wdpcIntervals), $verbose, __FILE__, __LINE__);
            // generate fio JSON output
            $controller->generateJson();
            $controllers[$test] =& $controller;
        } else {
            print_msg(sprintf('Workload dependent preconditioning for test %s failed', strtoupper($test)), $verbose, __FILE__, __LINE__, TRUE);
        }
        $controller->stop();
    } else {
        print_msg(sprintf('Unable to get %s test controller', $test), $verbose, __FILE__, __LINE__, TRUE);
    }
}
// generate report
if (!$exitCode && count($controllers)) {
    print_msg(sprintf('Generating reports...'), $verbose, __FILE__, __LINE__);
    BlockStorageTest::generateReports($controllers);
    print_msg(sprintf('Report generation complete'), $verbose, __FILE__, __LINE__);
}
print_msg(sprintf('Exiting with status code %d', $exitCode), $verbose, __FILE__, __LINE__);
exit($exitCode);
Beispiel #26
0
function db_quickQuery($db, $query, $noResultsError = false, $debug = 0, $profile = 0)
{
    $results = db_query($db, $query, $debug, $profile);
    if (db_numRows($results) > 0) {
        return db_row($results, 0);
    } else {
        if ($noResultsError) {
            print_msg('ERROR', "db_quickQuery(...)", "0 rows returned on the following query:<BR><PRE>" . $query . "</PRE>");
        }
    }
    return false;
}
function migrate_tplan_contents(&$source_db, &$target_db, &$tmp_table_name, &$tc_tcversion, &$old_new, &$migrator)
{
    $items_processed = 0;
    // how many records are we going to tackle at a time
    // with basic benchmarking roughly 500 seemed to be slightly faster
    $step_amt = 500;
    $tc_count = $migrator->get_tmp_table_count("tp");
    print_msg("<b><center>Migrating Test Plans - " . date("H:i:s") . " -</center></b><br />");
    print_msg("Total number of TC in ALL TPlan: {$tc_count}<br />");
    // Make sure we have enough memory to do what we are about to do
    check_memory($tc_count);
    while ($items_processed < $tc_count) {
        // make sure nothing is in tplan_elems
        $tplan_elems = null;
        echo "<br>items processed is {$items_processed}<br>";
        $query = "SELECT * FROM {$tmp_table_name} ORDER BY projid LIMIT {$items_processed},{$step_amt}";
        echo "<br>using query {$query}<br>";
        $tplan_elems = $source_db->get_recordset($query);
        //echo "<br>tpaln elems<br>";
        //print_r($tplan_elems);
        //echo "<br>tmp_table name is $tmp_table_name";
        echo "<br>there are " . count($tplan_elems) . " in tpalnelems<br>";
        foreach ($tplan_elems as $idata) {
            $tplan_id = $old_new['tplan'][intval($idata['projid'])];
            $tcversion_id = $tc_tcversion[$idata['mgttcid']];
            $sql = "INSERT INTO testplan_tcversions " . "(testplan_id,tcversion_id) " . "VALUES({$tplan_id},{$tcversion_id})";
            $target_db->exec_query($sql);
            ++$items_processed;
        }
    }
    echo "<br>finished migrating test plan assignments<br>";
}
 /**
  * Performs workload dependent preconditioning - this method must be 
  * implemented by sub-classes. It should return one of the following 
  * values:
  *   TRUE:  preconditioning successful and steady state achieved
  *   FALSE: preconditioning successful but steady state not achieved
  *   NULL:  preconditioning failed
  * @return boolean
  */
 public function wdpc()
 {
     $status = NULL;
     print_msg(sprintf('Initiating workload dependent preconditioning and steady state for LATENCY test'), $this->verbose, __FILE__, __LINE__);
     $max = $this->options['ss_max_rounds'];
     $ssMetrics = array();
     $blockSizes = $this->filterBlocksizes(array('8k', '4k', '512b'));
     $lastBlockSize = $blockSizes[count($blockSizes) - 1];
     $workloads = $this->filterWorkloads(array('100/0', '65/35', '0/100'));
     for ($x = 1; $x <= $max; $x++) {
         foreach ($workloads as $rw) {
             $pieces = explode('/', $rw);
             $read = $pieces[0] * 1;
             $write = $pieces[1] * 1;
             $rwmixread = 100 - $write;
             foreach ($blockSizes as $bs) {
                 $name = sprintf('x%d-%s-%s-rand', $x, str_replace('/', '_', $rw), $bs);
                 print_msg(sprintf('Executing random IO test iteration for round %d of %d, rw ratio %s and block size %s', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__);
                 $params = array('blocksize' => $bs, 'name' => $name, 'runtime' => $this->options['wd_test_duration'], 'time_based' => FALSE, 'numjobs' => count($this->options['target']), 'iodepth' => 1);
                 if ($read == 100) {
                     $params['rw'] = 'randread';
                 } else {
                     if ($write == 100) {
                         $params['rw'] = 'randwrite';
                     } else {
                         $params['rw'] = 'randrw';
                         $params['rwmixread'] = $rwmixread;
                     }
                 }
                 if ($fio = $this->fio($params, 'wdpc')) {
                     print_msg(sprintf('Random IO test iteration for round %d of %d, rw ratio %s and block size %s was successful', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__);
                     $results = $this->fio['wdpc'][count($this->fio['wdpc']) - 1];
                 } else {
                     print_msg(sprintf('Random IO test iteration for round %d of %d, rw ratio %s and block size %s failed', $x, $max, $rw, $bs), $this->verbose, __FILE__, __LINE__, TRUE);
                     break;
                 }
                 if ($rw == '0/100' && $bs == '4k') {
                     $latency = $this->getLatency($results['jobs'][0]);
                     print_msg(sprintf('Added Latency metric %s ms for steady state verification', $latency), $this->verbose, __FILE__, __LINE__);
                     $ssMetrics[$x] = $latency;
                 }
                 // check for steady state
                 if ($x >= 5 && $rw == '0/100' && $bs == $lastBlockSize) {
                     $metrics = array();
                     for ($i = 4; $i >= 0; $i--) {
                         $metrics[$x - $i] = $ssMetrics[$x - $i];
                     }
                     print_msg(sprintf('Test round %d of %d complete and >= 5 rounds finished - checking if steady state has been achieved using 4k write latency metrics [%s],[%s]', $x, $max, implode(',', array_keys($metrics)), implode(',', $metrics)), $this->verbose, __FILE__, __LINE__);
                     if ($this->isSteadyState($metrics, $x)) {
                         print_msg(sprintf('Steady state achieved - testing will stop'), $this->verbose, __FILE__, __LINE__);
                         $status = TRUE;
                     } else {
                         print_msg(sprintf('Steady state NOT achieved'), $this->verbose, __FILE__, __LINE__);
                     }
                     // end of the line => last test round and steady state not achieved
                     if ($x == $max && $status === NULL) {
                         $status = FALSE;
                     }
                 }
                 if (!$fio || $status !== NULL) {
                     break;
                 }
             }
             if (!$fio || $status !== NULL) {
                 break;
             }
         }
         if (!$fio || $status !== NULL) {
             break;
         }
     }
     // set wdpc attributes
     $this->wdpc = $status;
     $this->wdpcComplete = $x;
     $this->wdpcIntervals = count($workloads) * count($blockSizes);
     return $status;
 }
Beispiel #29
0
function print_aside_deck($id)
{
    global $DECK_SINGLE_TABLE_ATTR;
    $table = get_deck_table_name($id);
    print_msg(get_deck_name_by_id($id));
    $total = print_table($table, $DECK_SINGLE_TABLE_ATTR, 'print_single_deck_table_callback');
    print_msg("total = {$total}");
}
Beispiel #30
0
                                    if ($db->addRow('fio', $row)) {
                                        print_msg(sprintf('Successfully saved job %s to fio table', $row['jobname']), isset($args['verbose']), __FILE__, __LINE__);
                                    } else {
                                        print_msg(sprintf('Failed to save job %s to fio table', $row['jobname']), isset($args['verbose']), __FILE__, __LINE__, TRUE);
                                    }
                                } else {
                                    print_msg(sprintf('Unable to get fio row data for job %s', $row['jobname']), isset($args['verbose']), __FILE__, __LINE__, TRUE);
                                }
                            }
                        } else {
                            print_msg(sprintf('Failed to save fio results from file %s', basename($file)), isset($args['verbose']), __FILE__, __LINE__, TRUE);
                        }
                    }
                } else {
                    print_msg(sprintf('%s fio results will not be saved because the --nosave_fio argument was set', $test), isset($args['verbose']), __FILE__, __LINE__);
                }
            } else {
                print_msg(sprintf('Skipping test %s because results are not present', $test), isset($args['verbose']), __FILE__, __LINE__);
            }
        }
    }
    // finalize saving of results
    if ($db->save()) {
        print_msg(sprintf('Successfully saved test results from directory %s', $dir), isset($args['verbose']), __FILE__, __LINE__);
        $status = 0;
    } else {
        print_msg(sprintf('Unable to save test results from directory %s', $dir), isset($args['verbose']), __FILE__, __LINE__, TRUE);
        $status = 1;
    }
}
exit($status);