How to use phoromatic_systems class

Best Phoronix-test-suite code snippet using phoromatic_systems

phoromatic_systems.php

Source:phoromatic_systems.php Github

copy

Full Screen

...14 GNU General Public License for more details.15 You should have received a copy of the GNU General Public License16 along with this program. If not, see <http://www.gnu.org/licenses/>.17*/18class phoromatic_systems implements pts_webui_interface19{20 public static function page_title()21 {22 return 'Systems';23 }24 public static function page_header()25 {26 return null;27 }28 public static function preload($PAGE)29 {30 return true;31 }32 public static function render_page_process($PATH)33 {34 echo phoromatic_webui_header_logged_in();35 $main = null;36 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['system_title']) && !empty($_POST['system_title']) && isset($_POST['system_description']) && isset($_POST['system_state']))37 {38 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET Title = :title, Description = :description, State = :state, CurrentTask = \'Awaiting Task\', BlockPowerOffs = :block_power_offs WHERE AccountID = :account_id AND SystemID = :system_id');39 $stmt->bindValue(':account_id', $_SESSION['AccountID']);40 $stmt->bindValue(':system_id', $PATH[0]);41 $stmt->bindValue(':title', $_POST['system_title']);42 $stmt->bindValue(':description', $_POST['system_description']);43 $stmt->bindValue(':state', $_POST['system_state']);44 $stmt->bindValue(':block_power_offs', $_POST['block_power_offs']);45 $stmt->execute();46 }47 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['maintenance_mode']))48 {49 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET MaintenanceMode = :maintenance_mode WHERE AccountID = :account_id AND SystemID = :system_id');50 $stmt->bindValue(':account_id', $_SESSION['AccountID']);51 $stmt->bindValue(':system_id', $PATH[0]);52 $stmt->bindValue(':maintenance_mode', $_POST['maintenance_mode']);53 $stmt->execute();54 }55 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_GET['clear_system_warnings']))56 {57 $stmt = phoromatic_server::$db->prepare('DELETE FROM phoromatic_system_client_errors WHERE AccountID = :account_id AND SystemID = :system_id');58 $stmt->bindValue(':account_id', $_SESSION['AccountID']);59 $stmt->bindValue(':system_id', $PATH[0]);60 $stmt->execute();61 }62 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['tick_thread_reboot']))63 {64 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET TickThreadEvent = :event WHERE AccountID = :account_id AND SystemID = :system_id');65 $stmt->bindValue(':account_id', $_SESSION['AccountID']);66 $stmt->bindValue(':system_id', $PATH[0]);67 $stmt->bindValue(':event', time() . ':reboot');68 $stmt->execute();69 }70 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['tick_thread_halt']))71 {72 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET TickThreadEvent = :event WHERE AccountID = :account_id AND SystemID = :system_id');73 $stmt->bindValue(':account_id', $_SESSION['AccountID']);74 $stmt->bindValue(':system_id', $PATH[0]);75 $stmt->bindValue(':event', time() . ':halt-testing');76 $stmt->execute();77 }78 if(!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['system_var_names'])&& isset($_POST['system_var_values']))79 {80 $vars = array();81 foreach($_POST['system_var_names'] as $i => $name)82 {83 if(isset($_POST['system_var_values'][$i]))84 {85 $name = pts_strings::keep_in_string(strtoupper($name), pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_UNDERSCORE);86 $val = pts_strings::keep_in_string($_POST['system_var_values'][$i], pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_SLASH | pts_strings::CHAR_SPACE | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_PLUS | pts_strings::CHAR_EQUAL);87 if($name != null)88 {89 $vars[$name] = $val;90 }91 }92 }93 $var_string = null;94 foreach($vars as $name => $val)95 {96 $var_string .= $name . '=' . $val . ';';97 }98 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET SystemVariables = :system_variables WHERE AccountID = :account_id AND SystemID = :system_id');99 $stmt->bindValue(':account_id', $_SESSION['AccountID']);100 $stmt->bindValue(':system_id', $PATH[0]);101 $stmt->bindValue(':system_variables', $var_string);102 $stmt->execute();103 }104 if(!empty($PATH[0]))105 {106 $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id ORDER BY LastCommunication DESC');107 $stmt->bindValue(':account_id', $_SESSION['AccountID']);108 $stmt->bindValue(':system_id', $PATH[0]);109 $result = $stmt->execute();110 if(!empty($result))111 {112 $row = $result->fetchArray();113 if(!PHOROMATIC_USER_IS_VIEWER && isset($PATH[1]) && $PATH[1] == 'edit')114 {115 $main = '<h1>' . $row['Title'] . '</h1>';116 $main .= '<form name="system_form" id="system_form" action="?systems/' . $PATH[0] . '" method="post" onsubmit="return phoromatic_system_edit(this);">117 <p><div style="width: 200px; font-weight: bold; float: left;">System Title:</div> <input type="text" style="width: 400px;" name="system_title" value="' . $row['Title'] . '" /></p>118 <p><div style="width: 200px; font-weight: bold; float: left;">System Description:</div> <textarea style="width: 400px;" name="system_description">' . $row['Description'] . '</textarea></p>119 <p><div style="width: 200px; font-weight: bold; float: left;">System State:</div><select name="system_state" style="width: 200px;"><option value="-1">Disabled</option><option value="1" selected="selected">Enabled</option></select></p>120 <p><div style="width: 200px; font-weight: bold; float: left;">Allow Phoromatic To Power Off System When Testing Complete:</div><select name="block_power_offs" style="width: 200px;"><option value="0">Permitted</option><option value="1">Block Power-Off Signaling For This System</option></select> <sup>Assuming the power-off setting is enabled from the account settings page.</sup></p>121 <p><div style="width: 200px; font-weight: bold; float: left;">&nbsp;</div> <input type="submit" value="Submit" /></p></form>';122 }123 else124 {125 $main = '<h1>' . $row['Title'] . '</h1><p><em>' . ($row['Description'] != null ? $row['Description'] : 'No system description.') . '</em></p>';126 if(phoromatic_server::system_check_if_down($_SESSION['AccountID'], $row['SystemID'], $row['LastCommunication'], $row['CurrentTask']))127 {128 $main .= '<h3 style="text-align: center; color: red;">This system appears to be offline or inactive and there are pending tests scheduled to be run on this system that have yet to be completed. This system has not communicated with the Phoromatic Server in ' . pts_strings::format_time((time() - strtotime($row['LastCommunication'])), 'SECONDS', true, 60) . '.</h3>';129 }130 if(!PHOROMATIC_USER_IS_VIEWER)131 {132 $main .= '<p><a href="?systems/' . $PATH[0] . '/edit">Edit Task & Enable/Disable System</a></p>';133 }134 }135 switch($row['State'])136 {137 case -1:138 $state = 'Disabled';139 break;140 case 0:141 $state = 'Connected; Awaiting Approval';142 break;143 case 1:144 $state = 'Active';145 break;146 }147 $main .= '<hr />';148 $status_extra = null;149 if(!empty($row['CurrentProcessSchedule']))150 {151 $status_extra = ' - <a href="/?schedules/' . $row['CurrentProcessSchedule'] . '">' . phoromatic_server::schedule_id_to_name($row['CurrentProcessSchedule']) . '</a>';152 }153 else if(!empty($row['CurrentProcessTicket']))154 {155 $status_extra = ' - <a href="/?benchmark/' . $row['CurrentProcessTicket'] . '">' . phoromatic_server::ticket_id_to_name($row['CurrentProcessTicket']) . '</a>';156 }157 $info_table = array('Status:' => $row['CurrentTask'] . $status_extra, 'Last Communication:' => phoromatic_user_friendly_timedate($row['LastCommunication']), 'Estimated Time Left For Task: ' => phoromatic_compute_estimated_time_remaining_string($row['EstimatedTimeForTask'], $row['LastCommunication']), 'State:' => $state, 'Phoronix Test Suite Client:' => $row['ClientVersion'], 'Initial Creation:' => phoromatic_user_friendly_timedate($row['CreatedOn']), 'System ID:' => $row['SystemID'], 'Last IP:' => $row['LastIP'], 'MAC Address:' => $row['NetworkMAC'], 'Wake-On-LAN Information:' => (empty($row['NetworkWakeOnLAN']) ? 'N/A' : $row['NetworkWakeOnLAN']), 'Power-Off Sequence Permitted: ' => ($row['BlockPowerOffs'] == 1 ? 'Blocked' : 'Permitted'));158 $main .= '<h2>System State</h2>' . pts_webui::r2d_array_to_table($info_table, 'auto');159 if(!PHOROMATIC_USER_IS_VIEWER)160 {161 if($row['MaintenanceMode'] == 1)162 {163 $mm_str = 'Disable Maintenance Mode';164 $mm_val = 0;165 $mm_onclick = 'return true;';166 }167 else168 {169 $mm_str = 'Enter Maintenance Mode';170 $mm_val = 1;171 $mm_onclick = 'return confirm(\'Enter maintenance mode now?\');';172 }173 $main .= '<p><form action="' . $_SERVER['REQUEST_URI'] . '" name="update_groups" method="post"><input type="hidden" name="maintenance_mode" value="' . $mm_val . '" /><input type="submit" value="' . $mm_str . '" onclick="' . $mm_onclick . '" style="float: left; margin: 0 20px 5px 0;" /></form> Putting the system into maintenance mode will power up the system (if supported and applicable) and cause the Phoronix Test Suite Phoromatic client to idle and block all testing until the mode has been disabled. If a test is already running on the system, the maintenance mode will not be entered until after the testing has completed. The maintenance mode can be used if wishing to update the system software or carry out other tasks without interfering with the Phoromatic client process. Once disabled, the Phoronix Test Suite will continue to function as normal.</p>';174 if($row['CoreVersion'] >= 5730)175 {176 $main .= '<p><form action="' . $_SERVER['REQUEST_URI'] . '" name="update_groups" method="post"><input type="hidden" name="tick_thread_reboot" value="1" /><input type="submit" value="Reboot System" style="float: left; margin: 0 20px 5px 0;" /></form> If the system is currently powered up and connected to the Phoromatic Server, this will send a message to the system to issue a reboot -- in case the system is hung on a test or you wish to otherwise manually reboot the server. This feature was added with Phoronix Test Suite 5.8.</p>';177 $main .= '<p><form action="' . $_SERVER['REQUEST_URI'] . '" name="update_groups" method="post"><input type="hidden" name="tick_thread_halt" value="1" /><input type="submit" value="Halt Testing" style="float: left; margin: 0 20px 5px 0;" /></form> If the system is currently powered up and running a test/benchmark via the Phoromatic Server, this will tell the system to halt the testing prematurely as soon as the currently-active test has finished. The results successfully ran will then be uploaded to the Phoromatic Server. This feature was added with Phoronix Test Suite 5.8.</p>';178 }179 }180 $main .= '<hr /><h2>System Variables</h2><p>System variables are a new feature of Phoronix Test Suite 5.6 to allow for providing per-system information in an easy-to-use manner for other parts of the Phoromatic system. Initially these named variables can be used for the results identifier when <a href="/?benchmark">creating a benchmark ticket</a> and in the future the system variables may be used elsewhere. Examples of system variables could include providing a <em>.SERIAL</em> variable to acknowledge the system\'s serial number that may not be presented elsewhere by the Phoronix Test Suite, <em>.ADMIN</em> for the system\'s local administrator, etc. Variable names can only be alpha-numeric strings while their values are also alpha-numeric strings but with spaces allowed. System variables are always prefixed by a period. These system variables are also automatically transferred to the Phoromatic clients and set as environment variables prior to running any scheduled tests/process via Phoromatic.</p>';181 $system_variables = explode(';', $row['SystemVariables']);182 $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="update_system_variables" method="post">';183 $main .= '<table width="80%"><tr><th>Variable Name</th><th>Value</th></tr>';184 foreach($system_variables as $i => $v_string)185 {186 $var = explode('=', $v_string);187 if(count($var) == 2)188 {189 $main .= '<tr id="system_var_' . $i . '">';190 $main .= '<td><span style="font-weight: 800; font-size: 16px;">.</span><input name="system_var_names[]" value="' . $var[0]. '" readonly /></td>';191 $main .= '<td><input name="system_var_values[]" value="' . $var[1]. '" readonly /></td>';192 $main .= '</tr>';193 }194 }195 $main .= '<tr id="system_var_' . ($i + 1) . '">';196 $main .= '<td><span style="font-weight: 800; font-size: 16px;">.</span><input name="system_var_names[]" /></td>';197 $main .= '<td><input name="system_var_values[]" /></td>';198 $main .= '</tr>';199 $main .= '</table>';200 $main .= '<p><input name="submit" value="Update System Variables" type="submit" /></p></form>';201 $main .= '<hr /><h2>System Components</h2><div style="float: left; width: 50%;">';202 $components = pts_result_file_analyzer::system_component_string_to_array($row['Hardware']);203 $main .= pts_webui::r2d_array_to_table($components) . '</div><div style="float: left; width: 50%;">';204 $components = pts_result_file_analyzer::system_component_string_to_array($row['Software']);205 $main .= pts_webui::r2d_array_to_table($components) . '</div>';206 $system_path = phoromatic_server::phoromatic_account_system_path($_SESSION['AccountID'], $row['SystemID']);207 $main .= '<hr />';208 if(is_file($system_path . 'sensors-pool.json'))209 {210 $sensors = file_get_contents($system_path . 'sensors-pool.json');211 $sensors = json_decode($sensors, true);212 foreach($sensors as $title => $s)213 {214 if(!isset($s['values']) || count($s['values']) < 5 || max($s['values']) == min($s['values']))215 {216 continue;217 }218 $graph = new pts_sys_graph(array('title' => $title, 'x_scale' => 'm', 'y_scale' => $s['unit'], 'text_size' => 12, 'reverse_x_direction' => false, 'width' => 920, 'height' => 400));219 $graph->render_base();220 $svg_dom = $graph->render_graph_data($s['values']);221 if($svg_dom === false)222 {223 continue;224 }225 $output_type = 'SVG';226 $graph = $svg_dom->output(null, $output_type);227 $main .= '<p align="center">' . substr($graph, strpos($graph, '<svg')) . '</p>';228 }229 }230 else if(is_file($system_path . 'sensors.json'))231 {232 $sensor_file = file_get_contents($system_path . 'sensors.json');233 $sensor_file = json_decode($sensor_file, true);234 if($sensor_file && isset($sensor_file['sensors']) && !empty($sensor_file['sensors']))235 {236 $i = 0;237 $col = array(1 => array(), 2 => array(), 3 => array(), 0 => array());238 foreach($sensor_file['sensors'] as $name => $sensor)239 {240 array_push($col[($i % 4)], '<strong>' . $name . ':</strong> ' . $sensor['value'] . ' ' . $sensor['unit']);241 $i++;242 }243 $main .= '<h2>System Sensors</h2>';244 foreach($col as $sensors)245 {246 $main .= '<div style="float: left; width: 25%;">';247 foreach($sensors as $sensor)248 $main .= '<p>' . $sensor . '</p>';249 $main .= '</div>';250 }251 $main .= '<p><em><strong>Last Updated:</strong>' . date('d F H:i', filemtime(phoromatic_server::phoromatic_account_system_path($_SESSION['AccountID'], $row['SystemID']) . 'sensors.json')) . ' <strong>System Uptime:</strong> ' . $sensor_file['uptime'] . ' Minutes</em></p>';252 }253 }254 $log_file = phoromatic_server::phoromatic_account_system_path($_SESSION['AccountID'], $row['SystemID']) . 'phoronix-test-suite.log';255 if(is_file($log_file))256 {257 $main .= '<hr /><h2>Phoronix Test Suite Client Log</h2>';258 $main .= '<p><textarea style="width: 60%; height: 200px;">' . file_get_contents($log_file) . '</textarea></p>';259 $main .= '<p><em><strong>Last Updated:</strong>' . date ('d F H:i', filemtime($log_file)) . '</em></p>';260 }261 $groups = explode('#', $row['Groups']);262 foreach($groups as $i => $group)263 {264 if(empty($group))265 unset($groups[$i]);266 }267 $schedules = phoromatic_server::schedules_that_run_on_system($_SESSION['AccountID'], $row['SystemID']);268 if(!empty($groups) || !empty($schedules))269 {270 $main .= '<hr /><h2>Schedules</h2>';271 if(!empty($groups))272 $group_msg = 'This system belongs to the following groups: <strong>' . implode(', ', $groups) . '</strong>.';273 else274 $group_msg = 'This system does not currently belong to any groups.';275 $main .= '<p>' . $group_msg . ' Manage groups via the <a href="?systems">systems page</a>.</p>';276 if(!empty($schedules))277 {278 $main .= '<div class="pts_phoromatic_info_box_area" style="margin: 0 10%;"><ul><li><h1>Schedules Running On This System</h1></li>';279 foreach($schedules as &$row)280 {281 $group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups']));282 $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>';283 }284 $main .= '</ul></div>';285 }286 }287 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, ScheduleID, PPRID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND SystemID = :system_id ORDER BY UploadTime DESC');288 $stmt->bindValue(':account_id', $_SESSION['AccountID']);289 $stmt->bindValue(':system_id', $PATH[0]);290 $test_result_result = $stmt->execute();291 $test_result_row = $test_result_result->fetchArray();292 $results = 0;293 if($test_result_row != false)294 {295 $main .= '<hr /><h2>Test Results</h2>';296 $main .= '<div class="pts_phoromatic_info_box_area" style="margin: 0 10%;">';297 $main .= '<ul><li><h1>Recent Test Results</h1></li>';298 do299 {300 if($results > 20)301 {302 break;303 }304 $main .= '<a href="?result/' . $test_result_row['PPRID'] . '"><li>' . $test_result_row['Title'] . '<br /><table><tr><td>' . phoromatic_system_id_to_name($test_result_row['SystemID']) . '</td><td>' . phoromatic_user_friendly_timedate($test_result_row['UploadTime']) . '</td></tr></table></li></a>';305 $results++;306 }307 while($test_result_row = $test_result_result->fetchArray());308 }309 if($results > 0)310 {311 $main .= '</ul></div>';312 }313 // Any System Errors?314 $stmt = phoromatic_server::$db->prepare('SELECT ErrorMessage, UploadTime, SystemID, TestIdentifier FROM phoromatic_system_client_errors WHERE AccountID = :account_id AND SystemID = :system_id ORDER BY UploadTime DESC LIMIT 10');315 $stmt->bindValue(':account_id', $_SESSION['AccountID']);316 $stmt->bindValue(':system_id', $PATH[0]);317 $result = $stmt->execute();318 $row = $result->fetchArray();319 if($row != false)320 {321 $main .= '<hr /><div class="pts_phoromatic_info_box_area" style="margin: 0 10%;"><ul><li><h1>Recent System Warnings &amp; Errors</h1></li>';322 do323 {324 $main .= '<a onclick=""><li>' . $row['ErrorMessage'] . '<br /><table><tr><td>' . $row['UploadTime'] . '</td><td>' . $row['TestIdentifier'] . '</td></tr></table></li></a>';325 }326 while($row = $result->fetchArray());327 $main .= ' </ul></div>';328 $main .= '<p align="center"><a href="?systems/' . $PATH[0] . '/&clear_system_warnings">Clear System Warnings/Errors</a></p>';329 }330 }331 }332 if($main == null)333 {334 if(!PHOROMATIC_USER_IS_VIEWER && isset($_POST['new_group']) && !empty($_POST['new_group']))335 {336 $group = trim($_POST['new_group']);337 if($group)338 {339 $stmt = phoromatic_server::$db->prepare('INSERT INTO phoromatic_groups (AccountID, GroupName) VALUES (:account_id, :group_name)');340 $stmt->bindValue(':account_id', $_SESSION['AccountID']);341 $stmt->bindValue(':group_name', $group);342 $result = $stmt->execute();343 phoromatic_add_activity_stream_event('groups', $group, 'added');344 if(!empty($_POST['systems_for_group']) && is_array($_POST['systems_for_group']))345 {346 foreach($_POST['systems_for_group'] as $sid)347 {348 // Find current groups349 $stmt = phoromatic_server::$db->prepare('SELECT Groups FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id ORDER BY LastCommunication DESC');350 $stmt->bindValue(':account_id', $_SESSION['AccountID']);351 $stmt->bindValue(':system_id', $sid);352 $result = $stmt->execute();353 $row = $result->fetchArray();354 $existing_groups = $row != false ? $row['Groups'] : null;355 // Append new Group356 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET Groups = :new_group WHERE AccountID = :account_id AND SystemID = :system_id');357 $stmt->bindValue(':account_id', $_SESSION['AccountID']);358 $stmt->bindValue(':system_id', $sid);359 $stmt->bindValue(':new_group', $existing_groups . '#' . $group . '#');360 $stmt->execute();361 }362 }363 }364 }365 else if(!PHOROMATIC_USER_IS_VIEWER && isset($_POST['system_group_update']))366 {367 $stmt = phoromatic_server::$db->prepare('SELECT SystemID FROM phoromatic_systems WHERE AccountID = :account_id');368 $stmt->bindValue(':account_id', $_SESSION['AccountID']);369 $result = $stmt->execute();370 phoromatic_add_activity_stream_event('groups', null, 'modified');371 while($row = $result->fetchArray())372 {373 if(isset($_POST['groups_' . $row['SystemID']]))374 {375 $group_string = null;376 foreach($_POST['groups_' . $row['SystemID']] as $group)377 {378 if($group != null)379 {380 $group_string .= '#' . $group . '#';381 }382 }383 $stmt1 = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET Groups = :new_groups WHERE AccountID = :account_id AND SystemID = :system_id');384 $stmt1->bindValue(':account_id', $_SESSION['AccountID']);385 $stmt1->bindValue(':system_id', $row['SystemID']);386 $stmt1->bindValue(':new_groups', $group_string);387 $stmt1->execute();388 }389 }390 }391 else if(!PHOROMATIC_USER_IS_VIEWER && isset($_POST['remove_group']))392 {393 $stmt = phoromatic_server::$db->prepare('DELETE FROM phoromatic_groups WHERE AccountID = :account_id AND GroupName = :group_name');394 $stmt->bindValue(':account_id', $_SESSION['AccountID']);395 $stmt->bindValue(':group_name', $_POST['remove_group']);396 $stmt->execute();397 phoromatic_add_activity_stream_event('groups', $group, 'removed');398 $stmt = phoromatic_server::$db->prepare('SELECT SystemID, Groups FROM phoromatic_systems WHERE AccountID = :account_id AND Groups LIKE \'%#' . $_POST['remove_group'] . '#%\'');399 $stmt->bindValue(':account_id', $_SESSION['AccountID']);400 $result = $stmt->execute();401 while($row = $result->fetchArray())402 {403 $revised_groups = str_replace('#' . $_POST['remove_group'] . '#', null, $row['Groups']);404 $stmt1 = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET Groups = :new_groups WHERE AccountID = :account_id AND SystemID = :system_id');405 $stmt1->bindValue(':account_id', $_SESSION['AccountID']);406 $stmt1->bindValue(':system_id', $row['SystemID']);407 $stmt1->bindValue(':new_groups', $revised_groups);408 $stmt1->execute();409 }410 }411 else if(!PHOROMATIC_USER_IS_VIEWER && isset($_POST['remove_inactive_systems']) && is_numeric($_POST['remove_inactive_systems']) && $_POST['remove_inactive_systems'] > 1)412 {413 // $_POST['remove_inactive_systems'] is number of days system is without activity before removing414 $stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET State = :state WHERE AccountID = :account_id AND (julianday() - julianday(LastCommunication)) > :inactive_days_before_removal');415 $stmt->bindValue(':account_id', $_SESSION['AccountID']);416 $stmt->bindValue(':state', -1);417 $stmt->bindValue(':inactive_days_before_removal', $_POST['remove_inactive_systems']);418 $stmt->execute();419 }420 $main = '<h1>Test Systems</h1>';421 if(!PHOROMATIC_USER_IS_VIEWER)422 {423 $main .= phoromatic_systems_needing_attention();424 $main .= '<h2>Add A System</h2>425 <p>To connect a <a href="http://www.phoronix-test-suite.com/">Phoronix Test Suite</a> test system to this account for remotely managing and/or carrying out routine automated benchmarking, follow these simple and quick steps:</p>426 <ol><li>From a system with <em>Phoronix Test Suite 5.4 or newer</em> run <strong>phoronix-test-suite phoromatic.connect ' . phoromatic_web_socket_server_addr() . '</strong>. (The test system must be able to access this server\'s correct IP address / domain name.)</li><li>When you have run the command from the test system, you will need to log into this page on Phoromatic server again where you can approve the system and configure the system settings so you can begin using it as part of this Phoromatic account.</li><li>Repeat the two steps for as many systems as you would like! When you are all done -- if you haven\'t done so already, you can start creating test schedules, groups, and other Phoromatic events.</li></ol>427 <p>Those having to connect many Phoronix Test Suite Phoromatic clients can also attempt <a href="?system_claim">adding the server configuration</a> via SSH or an IP/MAC address claim.</p>428 <p><button onclick="javascript:window.location.replace(\'?system_claim\');">Add Via SSH Or IP/MAC Claim</button></p>';429 }430 $main .= '<hr />431 <h2>Systems</h2>432 <div class="pts_phoromatic_info_box_area">433 <ul>434 <li><h1>Active Systems</h1></li>';435 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, LocalIP, CurrentTask, LastCommunication, EstimatedTimeForTask, TaskPercentComplete FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY LastCommunication DESC');436 $stmt->bindValue(':account_id', $_SESSION['AccountID']);437 $result = $stmt->execute();438 $row = $result->fetchArray();439 $active_system_count = 0;440 if($row == false)441 {442 $main .= '<li class="light" style="text-align: center;">No Systems Found</li>';443 }444 else445 {446 do447 {448 $acti = phoromatic_compute_estimated_time_remaining_string($row['EstimatedTimeForTask'], $row['LastCommunication']) . ($row['TaskPercentComplete'] > 0 ? ' [' . $row['TaskPercentComplete'] . '% Complete]' : null);449 if(empty($acti))450 {451 $next_job_in = phoromatic_server::time_to_next_scheduled_job($_SESSION['AccountID'], $row['SystemID']);452 if($next_job_in > 0)453 {454 if($next_job_in > 600)455 {456 $next_job_in = round($next_job_in / 60);457 $next_unit = 'hours';458 }459 else460 {461 $next_unit = 'minutes';462 }463 $acti = 'Next job in ' . $next_job_in . ' ' . $next_unit;464 }465 }466 $main .= '<a href="?systems/' . $row['SystemID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . $row['LocalIP'] . '</td><td><strong>' . $row['CurrentTask'] . '</strong></td><td><strong>' . $acti . '</strong></td><td><strong>Last Communication:</strong> ' . date('j F Y H:i', strtotime($row['LastCommunication'])) . '</td></tr></table></li></a>';467 $active_system_count++;468 }469 while($row = $result->fetchArray());470 }471 $main .= '</ul>';472 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, LocalIP, CurrentTask, LastCommunication, EstimatedTimeForTask, TaskPercentComplete FROM phoromatic_systems WHERE AccountID = :account_id AND State < 0 ORDER BY LastCommunication DESC');473 $stmt->bindValue(':account_id', $_SESSION['AccountID']);474 $result = $stmt->execute();475 $row = $result->fetchArray();476 if($row != false)477 {478 $main .= '<ul>479 <li><h1>Inactive Systems</h1></li>';480 do481 {482 $main .= '<a href="?systems/' . $row['SystemID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . $row['LocalIP'] . '</td><td><strong>' . $row['CurrentTask'] . '</strong></td><td><strong>Deactivated</strong></td><td><strong>Last Communication:</strong> ' . date('j F Y H:i', strtotime($row['LastCommunication'])) . '</td></tr></table></li></a>';483 }484 while($row = $result->fetchArray());485 $main .= '</ul>';486 }487 $main .= '</div>';488 if(!PHOROMATIC_USER_IS_VIEWER)489 {490 $main .= '<hr />491 <h2>System Groups</h2>492 <p>System groups make it very easy to organize multiple test systems for targeting by test schedules. You can always add/remove systems to groups, create new groups, and add systems to multiple groups. After creating a group and adding systems to the group, you can begin targeting tests against a particular group of systems. Systems can always be added/removed from groups later and a system can belong to multiple groups.</p>';493 $main .= '<div style="float: left;"><form name="new_group_form" id="new_group_form" action="?systems" method="post" onsubmit="return phoromatic_new_group(this);">494 <p><div style="width: 200px; font-weight: bold; float: left;">New Group Name:</div> <input type="text" style="width: 300px;" name="new_group" value="" /></p>495 <p><div style="width: 200px; font-weight: bold; float: left;">Select System(s) To Add To Group:</div><select name="systems_for_group[]" multiple="multiple" style="width: 300px;">';496 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY Title ASC');497 $stmt->bindValue(':account_id', $_SESSION['AccountID']);498 $result = $stmt->execute();499 $row = $result->fetchArray();500 if($row != false)501 {502 do503 {504 $main .= '<option value="' . $row['SystemID'] . '">' . $row['Title'] . '</option>';505 }506 while($row = $result->fetchArray());507 }508 $main .= '</select></p>509 <p><div style="width: 200px; font-weight: bold; float: left;">&nbsp;</div> <input type="submit" value="Create Group" /></p></form></div>';510 $stmt = phoromatic_server::$db->prepare('SELECT GroupName FROM phoromatic_groups WHERE AccountID = :account_id ORDER BY GroupName ASC');511 $stmt->bindValue(':account_id', $_SESSION['AccountID']);512 $result = $stmt->execute();513 $row = $result->fetchArray();514 if($row != false)515 {516 $main .= '<div style="float: left; margin-left: 90px;"><h3>Current System Groups</h3>';517 do518 {519 $stmt_count = phoromatic_server::$db->prepare('SELECT COUNT(SystemID) AS system_count FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 AND Groups LIKE \'%#' . $row['GroupName'] . '#%\'');520 $stmt_count->bindValue(':account_id', $_SESSION['AccountID']);521 $result_count = $stmt_count->execute();522 $row_count = $result_count->fetchArray();523 $row_count['system_count'] = isset($row_count['system_count']) ? $row_count['system_count'] : 0;524 $main .= '<div style="clear: both;"><div style="width: 200px; float: left; font-weight: bold;">' . $row['GroupName'] . '</div> ' . $row_count['system_count'] . ' System' . ($row_count['system_count'] != 1 ? 's' : '') . '</div>';525 }526 while($row = $result->fetchArray());527 $main .= '</div>';528 $main .= '<hr /><a name="group_edit"></a><h2>System Group Editing</h2><div style="text-align: center;"><form action="' . $_SERVER['REQUEST_URI'] . '" name="update_groups" method="post"><input type="hidden" name="system_group_update" value="1" />';529 $main .= '<table style="margin: 5px auto; overflow: auto;">';530 $main .= '<tr>';531 $main .= '<th></th>';532 $stmt = phoromatic_server::$db->prepare('SELECT GroupName FROM phoromatic_groups WHERE AccountID = :account_id ORDER BY GroupName ASC');533 $stmt->bindValue(':account_id', $_SESSION['AccountID']);534 $result = $stmt->execute();535 $all_groups = array();536 while($row = $result->fetchArray())537 {538 $main .= '<th>' . $row['GroupName'] . '</th>';539 array_push($all_groups, $row['GroupName']);540 }541 $main .= '</tr>';542 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID, Groups FROM phoromatic_systems WHERE AccountID = :account_id AND State >= 0 ORDER BY Title ASC');543 $stmt->bindValue(':account_id', $_SESSION['AccountID']);544 $result = $stmt->execute();545 while($row = $result->fetchArray())546 {547 $main .= '<tr>';548 $main .= '<th>' . $row['Title'] . '</th>';549 $main .= '<input type="hidden" name="groups_' . $row['SystemID'] . '[]" value="" />';550 foreach($all_groups as $group)551 {552 $checked = stripos($row['Groups'], '#' . $group . '#') !== false ? 'checked="checked" ' : null;553 $main .= '<td><input type="checkbox" name="groups_' . $row['SystemID'] . '[]" value="' . $group . '" ' . $checked . '/></td>';554 }555 $main .= '</tr>';556 }557 $main .= '</table><p><input name="submit" value="Update Groups" type="submit" /></p></form></div>';558 $main .= '<hr /><h2>Remove A Group</h2><p>Removing a group is a permanent action that cannot be undone.</p>';559 $main .= '<p><form action="' . $_SERVER['REQUEST_URI'] . '" name="remove_group" method="post"><select name="remove_group" id="remove_group">';560 foreach($all_groups as $group)561 {562 $main .= '<option value="' . $group . '">' . $group . '</option>';563 }564 $main .= '</select> <input name="submit" value="Remove Group" type="submit" /></form></p>';565 $main .= '<hr /><h2>Retire Inactive Systems</h2><p>This option will soft-delete systems that have not communicated with this Phoromatic Server in more than one week (7 days).</p>';566 $main .= '<p><form action="' . $_SERVER['REQUEST_URI'] . '" name="remove_inactive" method="post"><input type="hidden" name="remove_inactive_systems" value="7" /><input name="submit" value="Remove Inactive Systems" type="submit" /></form></p>';567 }568 }569 }570 $right = '<ul><li>Active Systems</li>';571 $stmt = phoromatic_server::$db->prepare('SELECT Title, SystemID FROM phoromatic_systems WHERE AccountID = :account_id AND State > 0 ORDER BY Title ASC');572 $stmt->bindValue(':account_id', $_SESSION['AccountID']);573 $result = $stmt->execute();574 $row = $result->fetchArray();575 if($row == false)576 {577 $right .= '</ul><p style="text-align: left; margin: 6px 10px;">No Systems Found</p>';578 }579 else580 {581 do582 {583 $right .= '<li><a href="?systems/' . $row['SystemID'] . '">' . $row['Title'] . '</a></li>';584 }585 while($row = $result->fetchArray());...

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/objects/phoromatic_systems.php');2require_once('pts-core/objects/phoromatic_user.php');3require_once('pts-core/objects/phoromatic_server.php');4require_once('pts-core/objects/phoromatic_result_viewer.php');5require_once('pts-core/objects/phoromatic_results_analyzer.php');6require_once('pts-core/objects/phoromatic_result_file_analyzer.php');7require_once('pts-core/objects/phoromatic_results_manager.php');8require_once('pts-core/objects/phoromatic_schedule.php');9require_once('pts-core/objects/phoromatic_account_manager.php');10require_once('pts-core/objects/phoromatic_upload.php');11require_once('pts-core/objects/phoromatic_experiment_results_viewer.php');12require_once('pts-core/objects/phoromatic_experiment_results_analyzer.php');13require_once('pts-core/objects/phoromatic_result_export.php');14require_once('pts-core/objects/phoromatic_result_viewer.php');15require_once('pts-core/objects/phoromatic_results_analyzer.php');16require_once('pts-core/objects/phoromatic_result_file_analyzer.php');

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/objects/phoromatic_systems.php');2require_once('pts-core/objects/phoromatic_server.php');3require_once('pts-core/objects/phoromatic_results.php');4require_once('pts-core/objects/phoromatic_accounts.php');5require_once('pts-core/objects/phoromatic_user.php');6require_once('pts-core/objects/phoromatic_schedule.php');7require_once('pts-core/objects/phoromatic_test_profile.php');8require_once('pts-core/objects/phoromatic_results_analyzer.php');9require_once('pts-core/objects/phoromatic_test_suite.php');10require_once('pts-core/objects/phoromatic_results_viewer.php');11require_once('pts-core/objects/phoromatic_upload.php');12require_once('pts-core/objects/phoromatic_web_socket_server.php');13require_once('pts-core/objects/phoromatic_web_socket_client.php');14require_once('pts-core/objects/phoromatic_web_socket_message.php');15require_once('pts-core/objects/phoromatic_web_socket_message_handler.php');16require_once('pts-core/objects/phoromatic_web_socket_message_handler_systems.php');

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1require_once('phoromatic_systems.php');2$phoromatic_systems = new phoromatic_systems();3$phoromatic_systems->get_systems();4{5 public function get_systems()6 {7 $db = new SQLite3('phoromatic.db');8 $systems = $db->query('SELECT * FROM phoromatic_systems');9 $systems_array = array();10 while($row = $systems->fetchArray())11 {12 $systems_array[] = $row;13 }14 return $systems_array;15 }16}17 (

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/objects/phoromatic_systems.php');2$phoromatic_systems = new phoromatic_systems;3$systems = $phoromatic_systems->get_all_systems();4foreach($systems as $system)5{6$system_id = $system['system_id'];7$system_name = $system['system_name'];8$system_description = $system['system_description'];9$system_status = $system['system_status'];10$system_ip = $system['system_ip'];11$system_last_login = $system['system_last_login'];

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1include_once('pts-core/phoromatic_systems.php');2$system_id = phoromatic_systems::system_id();3include_once('pts-core/phoromatic_server.php');4$server_id = phoromatic_server::server_id();5include_once('pts-core/phoromatic_user.php');6$user_id = phoromatic_user::user_id();7include_once('pts-core/phoromatic_result_parser.php');8$parser = new phoromatic_result_parser();9$parser->parse_file('result_file.xml');10$parser->parse_string($result_string);11$parser->parse_url('result_file_url');12include_once('pts-core/phoromatic_result_viewer.php');13$viewer = new phoromatic_result_viewer();14$viewer->view_file('result_file.xml');15$viewer->view_string($result_string);16$viewer->view_url('result_file_url');17include_once('pts-core/phoromatic_result_exporter.php');18$exporter = new phoromatic_result_exporter();19$exporter->export_file('result_file.xml');20$exporter->export_string($result_string);21$exporter->export_url('result_file_url');22include_once('pts-core/phoromatic_result_viewer.php');23$viewer = new phoromatic_result_viewer();24$viewer->view_file('result_file.xml');25$viewer->view_string($result_string);26$viewer->view_url('result_file_url');27include_once('pts-core/phoromatic_result_exporter.php');28$exporter = new phoromatic_result_exporter();29$exporter->export_file('result_file.xml');30$exporter->export_string($result_string);31$exporter->export_url('result_file_url');32include_once('pts-core

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1include 'phoromatic_systems.php';2$obj = new phoromatic_systems();3$systems = $obj->get_systems();4foreach($systems as $system)5{6';7}8include 'phoromatic_systems.php';9$obj = new phoromatic_systems();10$systems = $obj->get_systems();11foreach($systems as $system)12{13';14}15include 'phoromatic_systems.php';16$obj = new phoromatic_systems();17$system = $obj->get_system(1);18';

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/phoromatic_systems.php');2$system = new phoromatic_systems();3$system->load_system_info($_GET['system_id']);4$system->load_system_sensors();5$system_info = $system->system_info;6$system_sensors = $system->system_sensors;7echo $system_info['system_id'];8echo $system_info['system_name'];9echo $system_info['system_description'];10echo $system_info['system_ip'];11echo $system_info['system_last_contact'];12echo $system_info['system_last_active'];13echo $system_info['system_last_active_readable'];14echo $system_info['system_last_result'];15echo $system_info['system_last_result_readable'];16echo $system_info['system_last_result_id'];17echo $system_info['system_last_result_identifier'];18echo $system_info['system_last_result_details'];19echo $system_info['system_last_result_details_readable'];20echo $system_info['system_last_result_details_id'];21echo $system_info['system_last_result_details_identifier'];22echo $system_info['system_last_result_details_run_time'];23echo $system_info['system_last_result_details_run_time_readable'];24echo $system_info['system_last_result_details_run_time_seconds'];25echo $system_info['system_last_result_details_run_time_minutes'];26echo $system_info['system_last_result_details_run_time_hours'];27echo $system_info['system_last_result_details_run_time_days'];28echo $system_info['system_last_result_details_run_time_years'];29echo $system_info['system_last_result_details_run_time_readable'];30echo $system_info['system_last_result_details_run_time_seconds'];31echo $system_info['system_last_result_details_run_time_minutes'];32echo $system_info['system_last_result_details_run_time_hours'];33echo $system_info['system_last_result_details_run_time_days'];34echo $system_info['system_last_result_details_run_time_years'];35echo $system_info['system_last_result_details_run_time_readable'];36echo $system_info['system_last_result_details_run_time_seconds'];37echo $system_info['system_last_result_details_run_time_minutes'];38echo $system_info['system_last_result_details_run_time_hours'];39echo $system_info['system_last_result_details_run_time_days'];40echo $system_info['system_last_result_details_run_time_years'];41echo $system_info['system_last_result_details_run_time_readable'];42echo $system_info['system_last_result_details_run_time_seconds'];43echo $system_info['system_last_result_details_run_time_minutes'];

Full Screen

Full Screen

phoromatic_systems

Using AI Code Generation

copy

Full Screen

1include_once('/var/www/phoronix-test-suite/phoromatic/server/phoromatic_server.php');2$phoromatic_systems = new phoromatic_systems();3include_once('/var/www/phoronix-test-suite/phoromatic/server/classes/phoromatic_systems.php');4$systems = $phoromatic_systems->get_systems();5echo '<pre>';6print_r($systems);7echo '</pre>';8 (

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in phoromatic_systems

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful