示例#1
0
    while (is_dir($sdir = sprintf('%s/%d', $dir, $i++))) {
        $dirs[] = $sdir;
    }
} else {
    $dirs[] = $dir;
}
if ($db =& BenchmarkDb::getDb()) {
    // get results from each directory
    foreach ($dirs as $i => $dir) {
        $test = new NetworkTest($dir);
        $runOptions = $test->getRunOptions();
        if (!$verbose && isset($runOptions['verbose'])) {
            $verbose = TRUE;
        }
        $iteration = isset($args['iteration']) && preg_match('/([0-9]+)/', $args['iteration'], $m) ? $m[1] * 1 : $i + 1;
        if ($results = $test->getResults()) {
            print_msg(sprintf('Saving results in directory %s for iteration %d', $dir, $iteration), $verbose, __FILE__, __LINE__);
            foreach (array('nostore_rrd' => 'collectd-rrd.zip', 'nostore_rrd' => 'collectd-rrd.zip', 'nostore_traceroute' => 'traceroute.log') as $arg => $file) {
                $file = sprintf('%s/%s', $dir, $file);
                if (!isset($args[$arg]) && file_exists($file)) {
                    $pieces = explode('_', $arg);
                    $col = $arg == 'nostore_rrd' ? 'collectd_rrd' : $pieces[count($pieces) - 1];
                    $saved = $db->saveArtifact($file, $col);
                    if ($saved) {
                        print_msg(sprintf('Saved %s successfully', basename($file)), $verbose, __FILE__, __LINE__);
                    } else {
                        if ($saved === NULL) {
                            print_msg(sprintf('Unable to save %s', basename($file)), $verbose, __FILE__, __LINE__, TRUE);
                        } else {
                            print_msg(sprintf('Artifact %s will not be saved because --store was not specified', basename($file)), $verbose, __FILE__, __LINE__);
                        }
示例#2
-1
//
// 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.
/**
 * Renders results as key/value pairs. Keys are suffixed with a numeric 
 * value that is unique for each test (if more than 1 test performed)
 */
require_once dirname(__FILE__) . '/NetworkTest.php';
$status = 1;
$dir = count($argv) > 1 && is_file($argv[count($argv) - 1]) ? dirname($argv[count($argv) - 1]) : trim(shell_exec('pwd'));
$test = new NetworkTest($dir);
$options = parse_args(array('v' => 'verbose'));
if ($rows = $test->getResults()) {
    foreach ($rows as $i => $results) {
        $status = 0;
        $suffix = count($rows) > 1 ? $i + 1 : '';
        foreach ($results as $key => $val) {
            printf("%s%s=%s\n", $key, $suffix, $val);
        }
    }
}
exit($status);