private static function print_sensor($sensor, $device)
 {
     if ($sensor[0] === 'cgroup') {
         echo '- ' . phodevi::sensor_name($sensor) . PHP_EOL;
     } else {
         $sensor_object = new $sensor[2](0, $device);
         echo '- ' . phodevi::sensor_object_name($sensor_object) . ': ' . phodevi::read_sensor($sensor_object) . ' ' . phodevi::read_sensor_object_unit($sensor_object) . PHP_EOL;
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Supported Sensors');
     foreach (phodevi::supported_sensors() as $sensor) {
         echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
     }
     pts_client::$display->generic_heading('Unsupported Sensors');
     foreach (phodevi::unsupported_sensors() as $sensor) {
         echo '- ' . phodevi::sensor_name($sensor) . PHP_EOL;
     }
     echo PHP_EOL;
 }
 public function read_sensor_results($sensor, $offset = 0)
 {
     $results = $this->read_sensor_data($sensor, $offset);
     if (empty($results)) {
         return false;
     }
     return array('id' => phodevi::sensor_identifier($sensor), 'name' => phodevi::sensor_name($sensor), 'results' => $results, 'unit' => phodevi::read_sensor_unit($sensor));
 }
Esempio n. 4
0
 public static function run($r)
 {
     pts_openbenchmarking::refresh_repository_lists();
     pts_client::$display->generic_heading('Interactive Benchmarking');
     echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
     $reboot_on_exit = false;
     do {
         $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
         if (count(pts_client::saved_test_results()) > 0) {
             $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
         }
         $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
         $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
         switch ($response) {
             case 'RUN_TEST':
                 $supported_tests = pts_openbenchmarking::available_tests();
                 $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
                 $longest_title_length = 0;
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile->get_title() == null) {
                         unset($supported_tests[$i]);
                         continue;
                     }
                     $longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
                 }
                 $t = array();
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile instanceof pts_test_profile) {
                         $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
                     }
                 }
                 $supported_tests = $t;
                 asort($supported_tests);
                 $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
                 $tests_to_run = explode(',', $tests_to_run);
                 pts_test_installer::standard_install($tests_to_run);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($tests_to_run);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'RUN_SUITE':
                 $possible_suites = pts_openbenchmarking::available_suites();
                 foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
                     array_push($possible_suites, 'pts/' . $subsystem);
                 }
                 $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
                 foreach (explode(',', $suites_to_run) as $suite_to_run) {
                     pts_test_installer::standard_install($suite_to_run);
                     $run_manager = new pts_test_run_manager(false, 2);
                     $run_manager->standard_run($suite_to_run);
                 }
                 break;
             case 'SELECT_DRIVE_MOUNT':
                 self::select_drive_mount();
                 break;
             case 'RUN_SYSTEM_TEST':
                 pts_client::$display->generic_heading('System Test');
                 $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
                 pts_test_installer::standard_install($system_tests);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($system_tests);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'SHOW_INFO':
                 pts_client::$display->generic_heading('System Software / Hardware Information');
                 echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
                 echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
                 break;
             case 'SHOW_SENSORS':
                 pts_client::$display->generic_heading('Detected System Sensors');
                 foreach (phodevi::supported_sensors() as $sensor) {
                     echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
                 }
                 break;
             case 'SET_RUN_COUNT':
                 $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
                 putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
                 break;
             case 'BACKUP_RESULTS_TO_USB':
                 pts_client::$display->generic_heading('Backing Up Test Results');
                 foreach (pts_file_io::glob('/media/*') as $media_dir) {
                     if (!is_writable($media_dir)) {
                         echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
                         continue;
                     }
                     echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
                     pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
                     break;
                 }
                 break;
         }
         echo PHP_EOL . PHP_EOL;
     } while ($response != 'EXIT');
     if ($reboot_on_exit) {
         if (is_dir('/media/pts-auto-mount')) {
             pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
             exec('umount /media/pts-auto-mount 2>&1');
         }
         exec('reboot');
     }
 }
    public static function render_page_process($PATH)
    {
        if (PHOROMATIC_USER_IS_VIEWER) {
            return;
        }
        $is_new = true;
        if (!empty($PATH[0]) && $PATH[0] == 'all') {
            $main = '<h1>Past Benchmark Tickets</h1>';
            $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND State >= 0 ORDER BY TicketIssueTime DESC');
            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
            $result = $stmt->execute();
            $main .= '<ol>';
            if ($result) {
                $row = $result->fetchArray();
                if (!empty($row)) {
                    do {
                        $main .= '<li><a href="?benchmark/' . $row['TicketID'] . '">' . $row['Title'] . '</a></li>';
                    } while ($row = $result->fetchArray());
                }
            } else {
                $main .= '<li>No Benchmark Tickets Found</li>';
            }
            $main .= '</ol>';
        } else {
            if (!empty($PATH[0]) && is_numeric($PATH[0])) {
                $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND TicketID = :ticket_id');
                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                $stmt->bindValue(':ticket_id', $PATH[0]);
                $result = $stmt->execute();
                $row = $result->fetchArray();
                if (!empty($row)) {
                    if (isset($_GET['remove'])) {
                        $stmt = phoromatic_server::$db->prepare('DELETE FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND TicketID = :ticket_id');
                        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                        $stmt->bindValue(':ticket_id', $PATH[0]);
                        $result = $stmt->execute();
                        header('Location: /?benchmark');
                    } else {
                        if (isset($_GET['repeat'])) {
                            $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_benchmark_tickets SET TicketIssueTime = :new_ticket_time, State = 1 WHERE AccountID = :account_id AND TicketID = :ticket_id');
                            $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                            $stmt->bindValue(':ticket_id', $PATH[0]);
                            $stmt->bindValue(':new_ticket_time', time());
                            $result = $stmt->execute();
                        } else {
                            if (isset($_GET['disable'])) {
                                $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_benchmark_tickets SET State = 0 WHERE AccountID = :account_id AND TicketID = :ticket_id');
                                $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                                $stmt->bindValue(':ticket_id', $PATH[0]);
                                $result = $stmt->execute();
                            }
                        }
                    }
                    $main = null;
                    $main .= '<h1>' . $row['Title'] . '</h1>';
                    $main .= '<h3>' . $row['Description'] . '</h3>';
                    $main .= '<p>This benchmark ticket was created on <strong>' . date('j F Y \\a\\t H:i', strtotime($row['LastModifiedOn'])) . '</strong> by <strong>' . $row['LastModifiedBy'] . '. The ticket was last issued for testing at ' . date('j F Y \\a\\t H:i', $row['TicketIssueTime']) . '</strong>.';
                    $main .= '<p> <a href="/?benchmark/' . $PATH[0] . '/&repeat">Repeat Ticket</a> &nbsp; &nbsp; &nbsp; <a href="/?benchmark/' . $PATH[0] . '/&remove">Remove Ticket</a>' . (!isset($_GET['disable']) && $row['State'] > 0 ? ' &nbsp; &nbsp; &nbsp; <a href="/?benchmark/' . $PATH[0] . '/&disable">End Ticket</a>' : null) . '</p>';
                    $main .= '<hr /><h1>System Targets</h1><ol>';
                    foreach (explode(',', $row['RunTargetSystems']) as $system_id) {
                        $main .= '<li><a href="?systems/' . $system_id . '">' . phoromatic_server::system_id_to_name($system_id) . '</a></li>';
                    }
                    $main .= '</ol>';
                    $main .= '<hr /><h1>Ticket Payload</h1>';
                    $main .= '<p>This ticket runs the <strong>' . $row['SuiteToRun'] . '</strong> test suite:</p>';
                    $main .= '<div style="max-height: 400px; overflow-y: scroll;">';
                    $xml_path = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID'], $row['SuiteToRun']) . 'suite-definition.xml';
                    if (is_file($xml_path)) {
                        $test_suite = new pts_test_suite($xml_path);
                        //	$main .= '<h2>' . $test_suite->get_title() . '</h2>';
                        //	$main .= '<p><strong>' . $test_suite->get_maintainer() . '</strong></p>';
                        //	$main .= '<p><em>' . $test_suite->get_description() . '</em></p>';
                        foreach ($test_suite->get_contained_test_result_objects() as $tro) {
                            $main .= '<h3>' . $tro->test_profile->get_title() . ' [' . $tro->test_profile->get_identifier() . ']</h3>';
                            $main .= '<p>' . $tro->get_arguments_description() . '</p>';
                        }
                        //$main .= '<hr />';
                    }
                    $main .= '</div><hr />';
                    $main .= '<div class="pts_phoromatic_info_box_area">';
                    $main .= '<div style="margin: 0 5%;"><ul style="max-height: 100%;"><li><h1>Test Results</h1></li>';
                    $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, ScheduleID, PPRID, UploadTime, TimesViewed FROM phoromatic_results WHERE AccountID = :account_id AND BenchmarkTicketID = :ticket_id ORDER BY UploadTime DESC');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $stmt->bindValue(':ticket_id', $PATH[0]);
                    $test_result_result = $stmt->execute();
                    $results = 0;
                    while ($test_result_row = $test_result_result->fetchArray()) {
                        $main .= '<a onclick=""><li id="result_select_' . $test_result_row['PPRID'] . '"><input type="checkbox" id="result_compare_checkbox_' . $test_result_row['PPRID'] . '" onclick="javascript:phoromatic_checkbox_toggle_result_comparison(\'' . $test_result_row['PPRID'] . '\');" onchange="return false;"></input> <span onclick="javascript:phoromatic_window_redirect(\'?result/' . $test_result_row['PPRID'] . '\');">' . $test_result_row['Title'] . '</span><br /><table><tr><td>' . phoromatic_system_id_to_name($test_result_row['SystemID']) . '</td><td>' . phoromatic_user_friendly_timedate($test_result_row['UploadTime']) . '</td><td>' . $test_result_row['TimesViewed'] . ' Times Viewed</td></table></li></a>';
                        $results++;
                    }
                    if ($results == 0) {
                        $main .= '<li class="light" style="text-align: center;">No Results Found</li>';
                    } else {
                        if ($results > 3) {
                            $main .= '<a onclick=""><li id="global_bottom_totals"><input type="checkbox" id="global_checkbox" onclick="javascript:phoromatic_toggle_checkboxes_on_page(this);" onchange="return false;"></input> <strong>' . $results . ' Results</strong></li></a>';
                        }
                    }
                    $main .= '</ul></div>';
                    $main .= '</div>';
                }
            } else {
                if (isset($_POST['benchmark_title']) && !empty($_POST['benchmark_title'])) {
                    $title = phoromatic_get_posted_var('benchmark_title');
                    $description = phoromatic_get_posted_var('benchmark_description');
                    $result_identifier = phoromatic_get_posted_var('benchmark_identifier');
                    $suite_to_run = phoromatic_get_posted_var('suite_to_run');
                    if (strlen($title) < 3) {
                        echo '<h2>Title must be at least three characters.</h2>';
                        exit;
                    }
                    if (strlen($result_identifier) < 3) {
                        echo '<h2>Identifier must be at least three characters.</h2>';
                        exit;
                    }
                    if (strlen($suite_to_run) < 3) {
                        echo '<h2>You must specify a suite to run.</h2>';
                        exit;
                    }
                    $run_target_systems = phoromatic_get_posted_var('run_on_systems', array());
                    $run_target_groups = phoromatic_get_posted_var('run_on_groups', array());
                    if (!is_array($run_target_systems)) {
                        $run_target_systems = array();
                    }
                    if (!is_array($run_target_groups)) {
                        $run_target_groups = array();
                    }
                    $run_target_systems = implode(',', $run_target_systems);
                    $run_target_groups = implode(',', $run_target_groups);
                    if ($is_new) {
                        do {
                            $ticket_id = rand(10, 999999);
                            $matching_tickets = phoromatic_server::$db->querySingle('SELECT TicketID FROM phoromatic_benchmark_tickets WHERE TicketID = \'' . $ticket_id . '\'');
                        } while (!empty($matching_tickets));
                    }
                    $env_vars = array();
                    if (is_numeric($_POST['PTS_CONCURRENT_TEST_RUNS']) && $_POST['PTS_CONCURRENT_TEST_RUNS'] > 0) {
                        array_push($env_vars, 'PTS_CONCURRENT_TEST_RUNS=' . $_POST['PTS_CONCURRENT_TEST_RUNS']);
                    }
                    if (is_numeric($_POST['TOTAL_LOOP_TIME']) && $_POST['TOTAL_LOOP_TIME'] > 0) {
                        array_push($env_vars, 'TOTAL_LOOP_TIME=' . $_POST['TOTAL_LOOP_TIME']);
                    }
                    $env_vars = implode(';', $env_vars);
                    // Add benchmark
                    $stmt = phoromatic_server::$db->prepare('INSERT OR REPLACE INTO phoromatic_benchmark_tickets (AccountID, TicketID, TicketIssueTime, Title, ResultIdentifier, SuiteToRun, Description, State, LastModifiedBy, LastModifiedOn, RunTargetGroups, RunTargetSystems, EnvironmentVariables) VALUES (:account_id, :ticket_id, :ticket_time, :title, :result_identifier, :suite_to_run, :description, :state, :modified_by, :modified_on, :run_target_groups, :run_target_systems, :environment_variables)');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $stmt->bindValue(':ticket_id', $ticket_id);
                    $stmt->bindValue(':ticket_time', time());
                    $stmt->bindValue(':title', $title);
                    $stmt->bindValue(':result_identifier', $result_identifier);
                    $stmt->bindValue(':suite_to_run', $suite_to_run);
                    $stmt->bindValue(':description', $description);
                    $stmt->bindValue(':state', 1);
                    $stmt->bindValue(':modified_by', $_SESSION['UserName']);
                    $stmt->bindValue(':modified_on', phoromatic_server::current_time());
                    $stmt->bindValue(':public_key', $public_key);
                    $stmt->bindValue(':run_target_groups', $run_target_groups);
                    $stmt->bindValue(':run_target_systems', $run_target_systems);
                    $stmt->bindValue(':environment_variables', $env_vars);
                    $result = $stmt->execute();
                    phoromatic_add_activity_stream_event('benchmark', $benchmark_id, $is_new ? 'added' : 'modified');
                    if ($result) {
                        header('Location: ?benchmark/' . $schedule_id);
                    }
                }
                $main = '
			<h2>' . ($is_new ? 'Create' : 'Edit') . ' A Benchmark</h2>
			<p>This page allows you to run a test suite -- consisting of a single or multiple test suites -- on a given set/group of systems right away at their next earliest possibility. This benchmark mode is an alternative to the <a href="?schedules">benchmark schedules</a> for reptitive/routine testing.</p>';
                $local_suites = pts_file_io::glob(phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID']) . '*/suite-definition.xml');
                if (empty($local_suites)) {
                    $main .= '<p><strong>Before you can create a benchmark ticket you must first <a href="?build_suite">create a test suite</a> with the tests you wish to run.</strong></p>';
                } else {
                    $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="run_benchmark" id="run_benchmark" method="post" enctype="multipart/form-data" onsubmit="return validate_run_benchmark();">
				<h3>Title:</h3>
				<p>The title is the name of the result file for this test run.</p>
				<p><input type="text" name="benchmark_title" value="' . (!$is_new ? $e_schedule['Title'] : null) . '" /></p>
				<h3>Test Run Identifier:</h3>
				<p>The test run identifier is the per-system name for the system(s) being benchmarked. The following variables may be used: <strong>.SYSTEM</strong>, <strong>.GROUP</strong>. Any custom per-user system variables set via the individual system pages can also be used.</p>
				<p><input type="text" name="benchmark_identifier" value="' . (!$is_new ? $e_schedule['Identifier'] : null) . '" /></p>
				<h3>Test Suite To Run:</h3>
				<p><a href="?build_suite">Build a suite</a> to add/select more tests to run or <a href="?local_suites">view local suites</a> for more information on a particular suite. A test suite is a set of test profiles to run in a pre-defined manner.</p>';
                    $main .= '<p><select name="suite_to_run">';
                    foreach ($local_suites as $xml_path) {
                        $id = basename(dirname($xml_path));
                        $test_suite = new pts_test_suite($xml_path);
                        $main .= '<option value="' . $id . '">' . $test_suite->get_title() . ' - ' . $id . '</option>';
                    }
                    $main .= '</select></p>';
                    $main .= '<h3>Description:</h3>
				<p>The description is an optional way to add more details about the intent or objective of this test run.</p>
				<p><textarea name="benchmark_description" id="benchmark_description" cols="50" rows="3">' . (!$is_new ? $e_schedule['Description'] : null) . '</textarea></p>
				<hr /><h3>System Targets:</h3>
				<p>Select the systems that should be benchmarked at their next earliest convenience.</p>
				<p style="white-space: nowrap;">';
                    $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY Title ASC');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $result = $stmt->execute();
                    if (!$is_new) {
                        $e_schedule['RunTargetSystems'] = explode(',', $e_schedule['RunTargetSystems']);
                        $e_schedule['RunTargetGroups'] = explode(',', $e_schedule['RunTargetGroups']);
                    }
                    if ($row = $result->fetchArray()) {
                        $main .= '<h4>Systems: ';
                        do {
                            $main .= '<input type="checkbox" name="run_on_systems[]" value="' . $row['SystemID'] . '" ' . (!$is_new && in_array($row['SystemID'], $e_schedule['RunTargetSystems']) ? 'checked="checked" ' : null) . '/> ' . $row['Title'] . ' ';
                        } while ($row = $result->fetchArray());
                        $main .= '</h4>';
                    }
                    $stmt = phoromatic_server::$db->prepare('SELECT GroupName FROM phoromatic_groups WHERE AccountID = :account_id ORDER BY GroupName ASC');
                    $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                    $result = $stmt->execute();
                    if ($row = $result->fetchArray()) {
                        $main .= '<h4>Groups: ';
                        do {
                            $main .= '<input type="checkbox" name="run_on_groups[]" value="' . $row['GroupName'] . '" ' . (!$is_new && in_array($row['GroupName'], $e_schedule['RunTargetGroups']) ? 'checked="checked" ' : null) . '/> ' . $row['GroupName'] . ' ';
                        } while ($row = $result->fetchArray());
                        $main .= '</h4>';
                    }
                    $main .= '</p>
				<hr /><h3>Environment Options</h3>
				<h4>Stress Testing</h4>
				<p>If you wish to test systems for stability/reliability rather than performance, use this option and specify the number of tests to run concurrently (two or more) and (optionally) for the total period of time to continue looping the benchmarks. These options are intended to just stress the system and will not record any benchmark results. From the command-line this testing mode can be used via the <em>phoronix-test-suite stress-run</em> sub-command.</p>
				<p><strong>Concurrent Number Of Test Processes:</strong> <select name="PTS_CONCURRENT_TEST_RUNS"><option value="0">Disabled</option>';
                    for ($i = 2; $i <= 24; $i++) {
                        $main .= '<option value="' . $i . '">' . $i . '</option>';
                    }
                    $main .= '</select></p>
				<p><strong>Force Loop Time:</strong> <select name="TOTAL_LOOP_TIME"><option value="0">Disabled</option>';
                    $s = true;
                    for ($i = 60; $i <= 60 * 24 * 90; $i += 60) {
                        if ($i > 10080) {
                            // 7 days
                            if ($i % 1440 != 0) {
                                continue;
                            }
                        } else {
                            if ($i > 480) {
                                $s = !$s;
                                if (!$s) {
                                    continue;
                                }
                            }
                        }
                        $main .= '<option value="' . $i . '">' . pts_strings::format_time($i, 'MINUTES') . '</option>';
                    }
                    $main .= '</select></p>

				<h4>System Monitoring</h4>
				<p>The Phoronix Test Suite system monitor module allows for select hardware/software sensors to be logged in real-time while running the selected test suite. The supported sensors are then shown within the result file upon the test\'s completion.</p>';
                    foreach (phodevi::available_sensors() as $sensor) {
                        $main .= '<input type="checkbox" name="MONITOR" value="' . phodevi::sensor_identifier($sensor) . '" /> ' . phodevi::sensor_name($sensor) . ' &nbsp; ';
                    }
                    $main .= '<hr /><p align="left"><input name="submit" value="' . ($is_new ? 'Run' : 'Edit') . ' Benchmark" type="submit" onclick="return pts_rmm_validate_schedule();" /></p>
					</form>';
                }
            }
        }
        $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_benchmark_tickets WHERE AccountID = :account_id AND State >= 0 AND TicketIssueTime > :time_cutoff ORDER BY TicketIssueTime DESC LIMIT 30');
        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
        $stmt->bindValue(':time_cutoff', time() - 60 * 60 * 24 * 14);
        $result = $stmt->execute();
        $right = '<ul><li>Benchmark Tickets</li>';
        if ($result) {
            $row = $result->fetchArray();
            if (!empty($row)) {
                do {
                    $right .= '<li><a href="?benchmark/' . $row['TicketID'] . '">' . $row['Title'] . '</a></li>';
                } while ($row = $result->fetchArray());
            }
        }
        $right .= '<li><em><a href="?benchmark/all">View All Past Tickets</a></em></li>';
        $right .= '</ul>';
        echo phoromatic_webui_header_logged_in();
        echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in($right));
        echo phoromatic_webui_footer();
    }
Esempio n. 6
0
 protected static function tick_thread()
 {
     static $last_phoromatic_log = 0;
     while (true) {
         $j = array();
         $log_size = pts_client::$pts_logger->get_log_file_size();
         if ($log_size != $last_phoromatic_log) {
             $phoromatic_log = file_get_contents(pts_client::$pts_logger->get_log_file_location());
             $last_phoromatic_log = $log_size;
             $j['phoromatic']['client-log'] = $phoromatic_log;
         }
         foreach (phodevi::supported_sensors() as $sensor) {
             $j['phoromatic']['stats']['sensors'][phodevi::sensor_name($sensor)] = array('value' => phodevi::read_sensor($sensor), 'unit' => phodevi::read_sensor_unit($sensor));
         }
         $j['phoromatic']['stats']['uptime'] = ceil(phodevi::system_uptime() / 60);
         $server_response = phoromatic::upload_to_remote_server(array('r' => 'tick', 'j' => json_encode($j)));
         $server_response = json_decode($server_response, true);
         if ($server_response && isset($server_response['phoromatic']['tick_thread'])) {
             switch ($server_response['phoromatic']['tick_thread']) {
                 case 'reboot':
                     if (pts_client::executable_in_path('reboot')) {
                         shell_exec('reboot');
                     }
                     break;
                 case 'halt-testing':
                     touch(PTS_USER_PATH . 'halt-testing');
                     break;
             }
         }
         sleep(60);
     }
 }
 public static function __event_results_process(&$test_run_manager)
 {
     if (count(self::$perf_per_watt_collection) > 2) {
         // Performance per watt overall
         $avg = array_sum(self::$perf_per_watt_collection) / count(self::$perf_per_watt_collection);
         $test_profile = new pts_test_profile();
         $test_result = new pts_test_result($test_profile);
         $test_result->test_profile->set_test_title('Meta Performance Per Watt');
         $test_result->test_profile->set_identifier(null);
         $test_result->test_profile->set_version(null);
         $test_result->test_profile->set_result_proportion(null);
         $test_result->test_profile->set_display_format('BAR_GRAPH');
         $test_result->test_profile->set_result_scale('Performance Per Watt');
         $test_result->test_profile->set_result_proportion('HIB');
         $test_result->set_used_arguments_description('Performance Per Watt');
         $test_result->set_used_arguments('Per-Per-Watt');
         $test_result->test_result_buffer = new pts_test_result_buffer();
         $test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision($avg));
         $test_run_manager->result_file->add_result($test_result);
     }
     echo PHP_EOL . 'Finishing System Sensor Monitoring Process' . PHP_EOL;
     sleep(self::$sensor_monitoring_frequency * 4);
     foreach (self::$to_monitor as $sensor) {
         $sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor));
         pts_module::remove_file('logs/' . phodevi::sensor_identifier($sensor));
         if (count($sensor_results) > 2 && self::$monitor_test_count > 1) {
             $test_profile = new pts_test_profile();
             $test_result = new pts_test_result($test_profile);
             $test_result->test_profile->set_test_title(phodevi::sensor_name($sensor) . ' Monitor');
             $test_result->test_profile->set_identifier(null);
             $test_result->test_profile->set_version(null);
             $test_result->test_profile->set_result_proportion(null);
             $test_result->test_profile->set_display_format('LINE_GRAPH');
             $test_result->test_profile->set_result_scale(phodevi::read_sensor_unit($sensor));
             $test_result->set_used_arguments_description('Phoronix Test Suite System Monitoring');
             $test_result->set_used_arguments(phodevi::sensor_identifier($sensor));
             $test_result->test_result_buffer = new pts_test_result_buffer();
             $test_result->test_result_buffer->add_test_result(self::$result_identifier, implode(',', $sensor_results), implode(',', $sensor_results), implode(',', $sensor_results), implode(',', $sensor_results));
             $test_run_manager->result_file->add_result($test_result);
         }
     }
 }
 public static function run($r)
 {
     $is_moscow = pts_flags::os_identifier_hash() == 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc';
     if ($is_moscow) {
         // Auto mount?
         $drives = pts_file_io::glob('/dev/sda*');
         sort($drives);
         if (false && count($drives) > 0 && !is_dir('/media/pts-auto-mount') && is_writable('/media/')) {
             $last_drive = array_pop($drives);
             echo PHP_EOL . 'Attempting to auto-mount drive: ' . $last_drive . PHP_EOL;
             mkdir('/media/pts-auto-mount');
             exec('mount ' . $last_drive . ' /media/pts-auto-mount');
             putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
         }
         // Auto save results
         $test_results_name = phodevi::read_property('motherboard', 'serial-number');
         if ($test_results_name == null) {
             $test_results_name = phodevi::read_name('motherboard');
         }
         if ($test_results_name == null) {
             $test_results_name = phodevi::read_property('system', 'vendor-identifier');
         }
         putenv('TEST_RESULTS_NAME=' . str_replace(' ', null, $test_results_name));
         putenv('TEST_RESULTS_IDENTIFIER=' . $test_results_name);
         putenv('TEST_RESULTS_DESCRIPTION=Tests using ' . phodevi::read_property('system', 'operating-system') . ' on ' . date('d F Y') . ' of ' . $test_results_name . '.');
         self::select_drive_mount();
     }
     pts_openbenchmarking::refresh_repository_lists();
     pts_client::$display->generic_heading('Interactive Benchmarking');
     echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
     $reboot_on_exit = pts_flags::is_live_cd() && pts_client::user_home_directory() == '/root/';
     do {
         $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
         if ($is_moscow) {
             unset($options['RUN_SUITE']);
             //	$options['SELECT_DRIVE_MOUNT'] = 'Select Disk Drive To Use For Testing';
         }
         if (count(pts_client::saved_test_results()) > 0) {
             $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
         }
         $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
         $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
         switch ($response) {
             case 'RUN_TEST':
                 $supported_tests = pts_openbenchmarking::available_tests();
                 $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
                 $longest_title_length = 0;
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile->get_title() == null || pts_test_run_manager::test_profile_system_compatibility_check($test_profile) == false) {
                         unset($supported_tests[$i]);
                         continue;
                     }
                     if ($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false) {
                         // Don't show tests where files need to be downloaded
                         unset($supported_tests[$i]);
                         continue;
                     }
                     $longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
                 }
                 $t = array();
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile instanceof pts_test_profile) {
                         $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
                     }
                 }
                 $supported_tests = $t;
                 asort($supported_tests);
                 $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
                 $tests_to_run = explode(',', $tests_to_run);
                 pts_test_installer::standard_install($tests_to_run);
                 $run_manager = pts_test_run_manager::standard_run($tests_to_run, pts_c::defaults_mode | pts_c::auto_mode);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'RUN_SUITE':
                 $possible_suites = pts_openbenchmarking::available_suites();
                 foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
                     array_push($possible_suites, 'pts/' . $subsystem);
                 }
                 $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
                 foreach (explode(',', $suites_to_run) as $suite_to_run) {
                     pts_test_installer::standard_install($suite_to_run);
                     pts_test_run_manager::standard_run($suite_to_run, pts_c::defaults_mode | pts_c::auto_mode);
                 }
                 break;
             case 'SELECT_DRIVE_MOUNT':
                 self::select_drive_mount();
                 break;
             case 'RUN_SYSTEM_TEST':
                 pts_client::$display->generic_heading('System Test');
                 $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
                 pts_test_installer::standard_install($system_tests);
                 $run_manager = pts_test_run_manager::standard_run($system_tests, pts_c::defaults_mode | pts_c::auto_mode);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'SHOW_INFO':
                 pts_client::$display->generic_heading('System Software / Hardware Information');
                 echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
                 echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
                 break;
             case 'SHOW_SENSORS':
                 pts_client::$display->generic_heading('Detected System Sensors');
                 foreach (phodevi::supported_sensors() as $sensor) {
                     echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
                 }
                 break;
             case 'SET_RUN_COUNT':
                 $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
                 putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
                 break;
             case 'BACKUP_RESULTS_TO_USB':
                 pts_client::$display->generic_heading('Backing Up Test Results');
                 if ($is_moscow) {
                     $drives = pts_file_io::glob('/dev/sd*');
                     sort($drives);
                     if (count($drives) > 0 && is_writable('/media/')) {
                         $select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives);
                         echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL;
                         mkdir('/media/00-results-backup');
                         exec('mount ' . $select_drive . ' /media/00-results-backup');
                     }
                 }
                 foreach (pts_file_io::glob('/media/*') as $media_dir) {
                     if (!is_writable($media_dir)) {
                         echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
                         continue;
                     }
                     echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
                     pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
                     break;
                 }
                 if ($is_moscow && is_dir('/media/00-results-backup')) {
                     exec('umount /media/00-results-backup');
                     rmdir('/media/00-results-backup');
                 }
                 break;
         }
         echo PHP_EOL . PHP_EOL;
     } while ($response != 'EXIT');
     if ($reboot_on_exit) {
         if (is_dir('/media/pts-auto-mount')) {
             pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
             exec('umount /media/pts-auto-mount 2>&1');
         }
         exec('reboot');
     }
 }
 public static function __event_results_process(&$test_run_manager)
 {
     echo PHP_EOL . 'Finishing System Sensor Monitoring Process' . PHP_EOL;
     sleep(self::$sensor_monitoring_frequency * 4);
     foreach (self::$to_monitor as $sensor) {
         $sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor));
         pts_module::remove_file('logs/' . phodevi::sensor_identifier($sensor));
         if (count($sensor_results) > 2 && self::$monitor_test_count > 1) {
             $test_profile = new pts_test_profile();
             $test_result = new pts_test_result($test_profile);
             $test_result->test_profile->set_test_title(phodevi::sensor_name($sensor) . ' Monitor');
             $test_result->test_profile->set_identifier(null);
             $test_result->test_profile->set_version(null);
             $test_result->test_profile->set_result_proportion(null);
             $test_result->test_profile->set_display_format('LINE_GRAPH');
             $test_result->test_profile->set_result_scale(phodevi::read_sensor_unit($sensor));
             $test_result->set_used_arguments_description('Phoronix Test Suite System Monitoring');
             $test_result->set_used_arguments(phodevi::sensor_identifier($sensor));
             $test_run_manager->result_file_writer->add_result_from_result_object_with_value_string($test_result, implode(',', $sensor_results), implode(',', $sensor_results));
         }
     }
 }