コード例 #1
0
function phoromatic_compute_estimated_time_remaining_string($estimated_minutes, $last_comm, $append = 'Remaining')
{
    $remaining = phoromatic_compute_estimated_time_remaining($estimated_minutes, $last_comm);
    return $remaining > 0 ? '~' . pts_strings::plural_handler($remaining, 'Minute') . ' ' . $append : null;
}
コード例 #2
0
    public static function render_page_process($PATH)
    {
        echo phoromatic_webui_header_logged_in();
        $main = '<h1>Phoromatic</h1>';
        $main .= phoromatic_systems_needing_attention();
        $main .= '<p>Phoromatic is the remote management and test orchestration component to the <a href="http://www.phoronix-test-suite.com/">Phoronix Test Suite</a>. Phoromatic allows you to take advantage of the Phoronix Test Suite\'s vast feature-set across multiple systems over the LAN/WAN, manage entire test farms of systems for benchmarking via a centralized interface, centrally collect test results, and carry out other enteprise-focused tasks.</p>';
        $main_page_message = phoromatic_server::read_setting('main_page_message');
        if (!PHOROMATIC_USER_IS_VIEWER) {
            $main .= '<p>To get started with your new account, the basic steps to get started include:</p>
				<ol>
					<li>Connect/sync the Phoronix Test Suite client systems (the systems to be benchmarked) to this account. In the simplest form, you just need to run the following command on the test systems: <strong>phoronix-test-suite phoromatic.connect ' . phoromatic_web_socket_server_addr() . '</strong>. For more information view the instructions on the <a href="?systems">systems page</a>.</li>
					<li>Configure your <a href="?settings">account settings</a>.</li>
					<li><a href="?schedules">Create a test schedule</a>. A schedule is for running test(s) on selected system(s) on a routine, timed basis or whenever a custom trigger is passed to the Phoromatic server. A test schedule could be for running benchmarks on a daily basis, whenever a new Git commit is applied to a code-base, or other events occurred. You can also enrich the potential by adding pre/post-test hooks for ensuring the system is set to a proper state for benchmarking. Alternatively, you can <a href="?benchmark">create a benchmark ticket</a> for one-time testing on one or more systems.</li>
					<li>View the automatically generated <a href="?results">test results</a>.</li>';
            if (!empty($main_page_message)) {
                $main .= '<li><strong>' . $main_page_message . '</strong></li>';
            } else {
                $main .= '<li><strong>If you are interested in Phoromatic and the Phoronix Test Suite for enterprise testing, please <a href="http://commercial.phoronix-test-suite.com/">contact us</a> for commercial support, custom test development, custom engineering services, and other professional services. It\'s not without corporate support and sponsorship that we can continue to develop this leading open-source Linux benchmarking software. If you run into any problems with our open-source software or would like to contribute patches, you can do so via our <a href="https://www.github.com/phoronix-test-suite/phoronix-test-suite">GitHub project</a>.</strong></li>
				</ol>';
            }
        } else {
            if (!empty($main_page_message)) {
                $main .= '<p><strong>' . $main_page_message . '</strong></p>';
            }
        }
        $main .= '<hr /><div id="phoromatic_fixed_main_table">';
        $systems_needing_attention = phoromatic_server::systems_appearing_down($_SESSION['AccountID']);
        $systems_idling = phoromatic_server::systems_idling($_SESSION['AccountID']);
        $systems_shutdown = phoromatic_server::systems_shutdown($_SESSION['AccountID']);
        $systems_running_tests = phoromatic_server::systems_running_tests($_SESSION['AccountID']);
        $main .= '<div id="phoromatic_main_table_cell">
			<h2>' . pts_strings::plural_handler(count($systems_running_tests), 'System') . ' Running Tests</h2>
			<h2>' . pts_strings::plural_handler(count($systems_idling), 'System') . ' Idling</h2>
			<h2>' . pts_strings::plural_handler(count($systems_shutdown), 'System') . ' Shutdown</h2>
			<h2>' . pts_strings::plural_handler(count($systems_needing_attention), 'System') . ' Needing Attention</h2>';
        $main .= '<hr /><h2>Systems Running Tests</h2>';
        $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 AND CurrentTask NOT LIKE \'%Idling%\' AND CurrentTask NOT LIKE \'%Shutdown%\' ORDER BY LastCommunication DESC');
        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
        $result = $stmt->execute();
        while ($result && ($row = $result->fetchArray())) {
            $main .= '<div class="phoromatic_overview_box">';
            $main .= '<h1><a href="?systems/' . $row['SystemID'] . '">' . $row['Title'] . '</a></h1>';
            $main .= $row['CurrentTask'] . '<br />';
            if (!empty($row['CurrentProcessSchedule'])) {
                $main .= '<a href="?schedules/' . $row['CurrentProcessSchedule'] . '">' . phoromatic_server::schedule_id_to_name($row['CurrentProcessSchedule']) . '</a><br />';
            }
            $time_remaining = phoromatic_compute_estimated_time_remaining($row['EstimatedTimeForTask'], $row['LastCommunication']);
            if ($time_remaining) {
                $main .= '<em>~ ' . pts_strings::plural_handler($time_remaining, 'Minute') . ' Remaining</em>';
            }
            $main .= '</div>';
        }
        $main .= '</div>';
        $schedules_today = phoromatic_server::schedules_today($_SESSION['AccountID']);
        $schedules_total = phoromatic_server::schedules_total($_SESSION['AccountID']);
        $benchmark_tickets_today = phoromatic_server::benchmark_tickets_today($_SESSION['AccountID']);
        $main .= '<div id="phoromatic_main_table_cell">
		<h2>' . pts_strings::plural_handler(count($schedules_today), 'Schedule') . ' Active Today</h2>
		<h2>' . pts_strings::plural_handler(count($schedules_total), 'Schedule') . ' In Total</h2>
		<h2>' . pts_strings::plural_handler(count($benchmark_tickets_today), 'Active Benchmark Ticket') . '</h2>
		<h2> &nbsp; </h2>';
        $main .= '<hr /><h2>Today\'s Scheduled Tests</h2>';
        foreach ($schedules_today as &$row) {
            $systems_for_schedule = phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID']);
            $extra_css = null;
            if (empty($systems_for_schedule)) {
                $extra_css = ' opacity: 0.4;';
            }
            list($h, $m) = explode('.', $row['RunAt']);
            $main .= '<div style="' . $extra_css . '" class="phoromatic_overview_box">';
            $main .= '<h1><a href="?schedules/' . $row['ScheduleID'] . '">' . $row['Title'] . '</a></h1>';
            if (!empty($systems_for_schedule)) {
                if ($row['RunAt'] > date('H.i')) {
                    $run_in_future = true;
                    $main .= '<h3>Runs In ' . pts_strings::format_time($h * 60 + $m - (date('H') * 60 + date('i')), 'MINUTES') . '</h3>';
                } else {
                    $run_in_future = false;
                    $main .= '<h3>Triggered ' . pts_strings::format_time(max(1, date('H') * 60 + date('i') - ($h * 60 + $m)), 'MINUTES') . ' Ago</h3>';
                }
            }
            foreach ($systems_for_schedule as $system_id) {
                $pprid = self::result_match($row['ScheduleID'], $system_id, date('Y-m-d'));
                if ($pprid) {
                    $main .= '<a href="?result/' . $pprid . '">';
                }
                $main .= phoromatic_server::system_id_to_name($system_id);
                if ($pprid) {
                    $main .= '</a>';
                } else {
                    if (!$run_in_future) {
                        $sys_info = self::system_info($system_id);
                        $last_comm_diff = time() - strtotime($sys_info['LastCommunication']);
                        $main .= ' <sup><a href="?systems/' . $system_id . '">';
                        if ($last_comm_diff > 3600) {
                            $main .= '<strong>Last Communication: ' . pts_strings::format_time($last_comm_diff, 'SECONDS', true, 60) . ' Ago</strong>';
                        } else {
                            $main .= $sys_info['CurrentTask'];
                        }
                        $main .= '</a></sup>';
                    }
                }
                $main .= '<br />';
            }
            $main .= '</div>';
        }
        $main .= '</div>';
        $results_today = phoromatic_server::test_results($_SESSION['AccountID'], strtotime('today'));
        $results_this_week = phoromatic_server::test_results($_SESSION['AccountID'], mktime(0, 0, 0, date('n'), date('j') - date('N') + 1));
        $results_total = phoromatic_server::test_results($_SESSION['AccountID'], null);
        $main .= '<div id="phoromatic_main_table_cell">
		<h2>' . pts_strings::plural_handler(count($results_today), 'Test Result') . ' Today</h2>
		<h2>' . pts_strings::plural_handler(count($results_this_week), 'Test Result') . ' This Week</h2>
		<h2>' . pts_strings::plural_handler(count($results_total), 'Test Result') . ' Total</h2>
		<h2>' . pts_strings::plural_handler(phoromatic_server::test_results_benchmark_count($_SESSION['AccountID']), 'Benchmark Result') . ' Total</h2>
		<hr /><h2>Today\'s Results</h2>';
        foreach ($results_today as $result) {
            $main .= '<h3><a href="?result/' . $result['PPRID'] . '">' . $result['Title'] . '</a></h3>';
        }
        $main .= '</div>';
        $main .= '</div>';
        /*
        		$has_flagged_results = false;
        		$stmt = phoromatic_server::$db->prepare('SELECT ScheduleID, GROUP_CONCAT(SystemID,\',\') AS Systems FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID NOT LIKE 0 GROUP BY ScheduleID ORDER BY UploadTime DESC');
        		$stmt->bindValue(':account_id', $_SESSION['AccountID']);
        		$test_result_result = $stmt->execute();
        		while($test_result_row = $test_result_result->fetchArray())
        		{
        			$systems = array_count_values(explode(',', $test_result_row['Systems']));
        
        			foreach($systems as $system_id => $system_count)
        			{
        				if($system_count < 2)
        					unset($systems[$system_id]);
        			}
        
        			$printed_schedule_name = false;
        			if(!empty($systems))
        			{
        				foreach(array_keys($systems) as $system_id)
        				{
        					$stmt_uploads = phoromatic_server::$db->prepare('SELECT PPRID, UploadID FROM phoromatic_results WHERE AccountID = :account_id AND SystemID = :system_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC LIMIT 2');
        					$stmt_uploads->bindValue(':account_id', $_SESSION['AccountID']);
        					$stmt_uploads->bindValue(':system_id', $system_id);
        					$stmt_uploads->bindValue(':schedule_id', $test_result_row['ScheduleID']);
        					$result_uploads = $stmt_uploads->execute();
        
        					$result_file = array();
        					$pprids = array();
        					while($result_uploads_row = $result_uploads->fetchArray())
        					{
        						$composite_xml = phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $result_uploads_row['UploadID']) . 'composite.xml';
        						if(is_file($composite_xml))
        						{
        							array_push($result_file, new pts_result_merge_select($composite_xml));
        						}
        						array_push($pprids, $result_uploads_row['PPRID']);
        					}
        					$result_file = array_reverse($result_file);
        
        					if(count($result_file) == 2)
        					{
        						$writer = new pts_result_file_writer(null);
        						$attributes = array();
        						pts_merge::merge_test_results_process($writer, $result_file, $attributes);
        						$result_file = new pts_result_file($writer->get_xml());
        
        						foreach($result_file->get_result_objects('ONLY_CHANGED_RESULTS') as $i => $result_object)
        						{
        							$vari = round($result_object->largest_result_variation(), 3);
        							if(abs($vari) < 0.03)
        								continue;
        							if(!$has_flagged_results)
        							{
        								$main .= '<hr /><h2>Flagged Results</h2>';
        								$main .= '<p>Displayed are results for each system of each scheduled test where there is a measurable change (currently set to a 0.1% threshold) when comparing the most recent result to the previous result for that system for that test schedule. Click on the change to jump to that individualized result file comparison.</p>';
        								$main .= '<span style="font-size: 80%;">';
        								$has_flagged_results = true;
        							}
        							if(!$printed_schedule_name)
        							{
        								$main .= '<h3>' . phoromatic_schedule_id_to_name($test_result_row['ScheduleID']) . '</h3><p>';
        								$printed_schedule_name = true;
        							}
        
        							$pcolor = $vari > 0 ? 'green' : 'red';
        
        							$main .= '<a href="?result/' . implode(',', $pprids) . '#' . $result_object->get_comparison_hash(true, false) . '"><span style="color: ' . $pcolor . ';"><strong>' . phoromatic_system_id_to_name($system_id) . ' - ' . $result_object->test_profile->get_title() . ':</strong> ' . implode(' &gt; ', $result_file->get_system_identifiers()) . ': ' . ($vari * 100) . '%</span></a><br />';
        						}
        					}
        				}
        			}
        			if($printed_schedule_name)
        				$main .= '</p>';
        		}
        		if($has_flagged_results)
        			$main .= '</span>';
        */
        // ACTIVE TEST SCHEDULES
        /*
        $main .= '<div style="float: left; width: 50%;"><ul><li><h1>Active Test Schedules</h1></li>';
        $stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, Description, RunTargetSystems, RunTargetGroups, ActiveOn, RunAt FROM phoromatic_schedules WHERE AccountID = :account_id AND State >= 1 ORDER BY Title ASC');
        $stmt->bindValue(':account_id', $_SESSION['AccountID']);
        $result = $stmt->execute();
        $row = $result->fetchArray();
        
        if($row == false)
        {
        	$main .= '<li class="light" style="text-align: center;">No Schedules Found</li>';
        }
        else
        {
        	do
        	{
        		$group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups']));
        		$main .= '<a href="?schedules/' . $row['ScheduleID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . pts_strings::plural_handler(count(phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID'])), 'System') . '</td><td>' . pts_strings::plural_handler($group_count, 'Group') . '</td><td>' . pts_strings::plural_handler(phoromatic_results_for_schedule($row['ScheduleID']), 'Result') . '</td><td><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></td></tr></table></li></a>';
        	}
        	while($row = $result->fetchArray());
        }
        $main .= '</ul></div>';
        */
        echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
        //echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in());
        echo phoromatic_webui_footer();
    }
コード例 #3
0
 public static function render_page_process($PATH)
 {
     echo phoromatic_webui_header_logged_in();
     $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY LastCommunication DESC');
     $stmt->bindValue(':account_id', $_SESSION['AccountID']);
     $result = $stmt->execute();
     echo '<script type="text/javascript"> setInterval(function() { window.location.reload(); }, 79000); </script>';
     echo '<div style="margin: 10px 0 30px; clear: both; padding-bottom: 40px;">';
     while ($row = $result->fetchArray()) {
         $opacity = null;
         // stripos($row['CurrentTask'], 'idling') !== false ||
         if (phoromatic_server::system_check_if_down($_SESSION['AccountID'], $row['SystemID'], $row['LastCommunication'], $row['CurrentTask']) || stripos($row['CurrentTask'], 'Unknown') !== false) {
             $not_testing = false;
             $opacity = ' style="background: #f44336; color: #FFF;"';
         } else {
             if (stripos($row['CurrentTask'], 'idling') !== false) {
                 $not_testing = true;
                 //	continue;
             } else {
                 if (stripos($row['CurrentTask'], 'waiting') !== false || stripos($row['CurrentTask'], 'shutdown') !== false) {
                     $not_testing = true;
                     $opacity = ' style="opacity: 0.3;"';
                 } else {
                     $not_testing = false;
                 }
             }
         }
         echo '<a href="?systems/' . $row['SystemID'] . '"><div class="phoromatic_dashboard_block"' . $opacity . '>';
         echo '<div style="float: left; width: 30%;">';
         echo '<h1>' . $row['Title'] . '</h1>';
         $components = array_merge(pts_result_file_analyzer::system_component_string_to_array($row['Hardware'], array('Processor', 'Motherboard')), pts_result_file_analyzer::system_component_string_to_array($row['Software'], array('OS', 'Kernel')));
         foreach ($components as &$c) {
             if (($x = stripos($c, ' @')) !== false) {
                 $c = substr($c, 0, $x);
             }
             if (($x = stripos($c, ' (')) !== false) {
                 $c = substr($c, 0, $x);
             }
         }
         echo '<p><em>' . implode(' - ', $components) . '</em></p>';
         echo '<h2>' . $row['CurrentTask'] . '</h2>';
         if (!empty($row['CurrentProcessSchedule'])) {
             echo '<h2>' . phoromatic_server::schedule_id_to_name($row['CurrentProcessSchedule']) . '</h2>';
         }
         echo '</div>';
         echo '<div style="float: left;">';
         echo '<h2>' . $row['LastIP'] . '</h2>';
         echo '</div>';
         $time_remaining = phoromatic_compute_estimated_time_remaining($row['EstimatedTimeForTask'], $row['LastCommunication']);
         if ($time_remaining) {
             echo '<div style="float: left; text-align: center; margin: 0 6px;">';
             echo '<h2>~ ' . $time_remaining . ' <sub>mins</sub></h2>';
             echo '<p class="font-size: 90%;"><em>Estimated Time Remaining</em></p>';
             if (!empty($row['TimeToNextCommunication'])) {
                 echo '<p><em>' . phoromatic_compute_estimated_time_remaining_string($row['TimeToNextCommunication'], $row['LastCommunication'], 'To Next Communication') . '</em></p>';
             }
             echo '</div>';
         }
         if ($not_testing) {
             $next_job_in = phoromatic_server::time_to_next_scheduled_job($_SESSION['AccountID'], $row['SystemID']);
             if ($next_job_in > 0) {
                 if ($next_job_in > 240) {
                     $next_job_in = round($next_job_in / 60);
                     $next_unit = 'hours';
                 } else {
                     $next_unit = 'mins';
                 }
                 echo '<div style="float: left; margin: 0 0 0 10px; text-align: center;">';
                 echo '<h2>' . $next_job_in . ' <sub>' . $next_unit . '</sub></h2>';
                 echo '<p class="font-size: 90%;"><em>Time To Next Scheduled Task</em></p>';
                 echo '</div>';
             }
         }
         $system_path = phoromatic_server::phoromatic_account_system_path($_SESSION['AccountID'], $row['SystemID']);
         if (is_file($system_path . 'sensors-pool.json')) {
             $sensors = file_get_contents($system_path . 'sensors-pool.json');
             $sensors = json_decode($sensors, true);
             echo '<div style="float: right; margin: 0 10px 0 10px;">';
             $g_count = 0;
             foreach (array('CPU Usage', 'Memory Usage', 'CPU Temperature', 'System Temperature', 'GPU Temperature', 'Swap Usage', 'System Iowait', 'CPU Frequency') as $s) {
                 if (!isset($sensors[$s]) || !isset($sensors[$s]['values']) || count($sensors[$s]['values']) < 5) {
                     continue;
                 }
                 $g_count++;
                 if ($g_count <= 3) {
                     $graph = new pts_sys_graph(array('title' => $s, 'x_scale' => 'm', 'y_scale' => $sensors[$s]['unit'], 'text_size' => 10, 'reverse_x_direction' => false, 'width' => 300, 'height' => 120));
                     $graph->render_base();
                     $svg_dom = $graph->render_graph_data($sensors[$s]['values']);
                     if ($svg_dom === false) {
                         continue;
                     }
                     $output_type = 'SVG';
                     $graph = $svg_dom->output(null, $output_type);
                     echo substr($graph, strpos($graph, '<svg'));
                 } else {
                     break;
                 }
             }
             echo '</div>';
         }
         echo '<hr style="width: ' . $row['TaskPercentComplete'] . '%;" />';
         echo '</div></a>';
     }
     echo '</div>';
     echo phoromatic_webui_footer();
 }