} foreach ($apps as $app) { $info = get_runtime_info($app->id); if ($xml) { echo " <app>\n"; echo " <id>" . $app->id . "</id>\n"; echo " <name>" . $app->name . "</name>\n"; echo " <unsent>" . get_mysql_count("result", "server_state = 2 and appid = " . $app->id) . "</unsent>\n"; echo " <in_progress>" . get_mysql_count("result", "server_state = 4 and appid = " . $app->id) . "</in_progress>\n"; echo " <avg_runtime>" . round($info->avg, 2) . "</avg_runtime>\n"; echo " <min_runtime>" . round($info->min, 2) . "</min_runtime>\n"; echo " <max_runtime>" . round($info->max, 2) . "</max_runtime>\n"; echo " <users_24h>" . $info->users . "</users_24h>\n"; echo " </app>\n"; } else { echo "<tr><td>" . $app->user_friendly_name . "</td>\n <td>" . number_format(get_mysql_count("result", "server_state = 2 and appid = " . $app->id)) . "</td>\n <td>" . number_format(get_mysql_count("result", "server_state = 4 and appid = " . $app->id)) . "</td>\n <td>"; echo number_format($info->avg, 2) . " (" . number_format($info->min, 2) . " - " . number_format($info->max, 2) . ")"; echo "</td>\n <td>" . number_format($info->users) . "</td>\n </tr>"; } } if ($xml) { echo " </tasks_by_app>\n"; } else { end_table(); } } $xmlstring = " </database_file_states>\n</server_status>\n"; if ($xml) { echo $xmlstring; } else { echo "\n </td>\n </tr>\n </table>\n ";
show_counts(tra("registered in past 24 hours"), "users_registered_in_past_24_hours", get_mysql_count("user where create_time > (unix_timestamp() - (24*3600))")); echo "<tr><th>" . tra("Computers") . "</th><th>#</th></tr>"; show_counts(tra("with recent credit"), "hosts_with_recent_credit", get_mysql_count("host where expavg_credit>1")); show_counts(tra("with credit"), "hosts_with_credit", get_mysql_count("host where total_credit>0")); show_counts(tra("registered in past 24 hours"), "hosts_registered_in_past_24_hours", get_mysql_count("host where create_time > (unix_timestamp() - (24*3600))")); // 200 cobblestones = 1 GigaFLOPS show_counts(tra("current GigaFLOPs"), "current_floating_point_speed", get_mysql_value("SELECT sum(expavg_credit)/200 as value FROM user")); end_table(); echo "</td></tr></table>"; start_table(); echo "<tr><th colspan=5>" . tra("Tasks by application") . "</th></tr>"; row_heading_array(array(tra("application"), tra("unsent"), tra("in progress"), tra("avg runtime of last 100 results in h (min-max)"), tra("users in last 24h"))); $apps = get_mysql_assoc("SELECT * FROM app WHERE deprecated != 1"); foreach ($apps as $app) { $appid = $app["id"]; $uf_name = $app["user_friendly_name"]; echo "<tr><td>{$uf_name}</td>\n <td>" . number_format(get_mysql_count("result where server_state = 2 and appid = {$appid}")) . "</td>\n <td>" . number_format(get_mysql_count("result where server_state = 4 and appid = {$appid}")) . "</td>\n <td>"; $info = get_runtime_info($appid); echo number_format($info->avg, 2) . " (" . number_format($info->min, 2) . " - " . number_format($info->max, 2) . ")"; echo "</td>\n <td>" . number_format(get_mysql_user("and appid = {$appid}")) . "</td>\n </tr>"; } end_table(); } } $xmlstring = " </database_file_states>\n</server_status>\n"; if ($xml) { echo $xmlstring; } else { echo "\n </td>\n </tr>\n </table>\n "; page_tail(); }
$cpu_string[20] = "AMD Turion"; $cpu_string[21] = "Intel Core2"; $query = "SELECT COUNT(workunit.id) AS count FROM workunit LEFT JOIN result ON workunit.id=result.workunitid WHERE result.server_state=2 AND workunit.hr_class="; function get_mysql_count($hr_class) { $result = mysql_query("select count(id) as count from workunit where hr_class=" . $hr_class); $count = mysql_fetch_object($result); mysql_free_result($result); return $count->count; } function make_reset_url($hr_class) { return "<a href=ops_reset_hrclass.php?hr_class=" . $hr_class . ">" . $hr_class . "</a>"; } db_init(); $timestr = time_str(time(0)); $title = "hr_class summary list at " . $timestr; admin_page_head($title); start_table(); row4("<b>hr_class</b>", "<b>System</b>", "<b>CPU</b>", "<b># unsent results</b>"); $unsentresults = get_mysql_count(0); row4(make_reset_url(0), $system_string[128], $cpu_string[0], $unsentresults); for ($system = 2; $system < 6; ++$system) { for ($cpu = 1; $cpu < 22; ++$cpu) { $hr_class = 128 * $system + $cpu; $unsentresults = get_mysql_count($hr_class); row4(make_reset_url($hr_class), $system_string[$system * 128], $cpu_string[$cpu], $unsentresults); } } end_table(); admin_page_tail();
} else { if (!$xml) { echo "\r\n\t\t\t<table border=0 cellpadding=4>\r\n\t\t\t<tr><th>State</th><th>#</th></tr>\r\n\t\t"; } // If you are reading these values from a file rather than // making live queries to the database, do something like this: // // $sendfile = "/home/boincadm/server_status_data/count_results_unsent.out"; // $n = `/bin/tail -1 $sendfile`; // show_counts("Results ready to send","results_ready_to_send",$n); show_counts("Results ready to send", "results_ready_to_send", get_mysql_count("result where server_state = 2")); show_counts("Results in progress", "results_in_progress", get_mysql_count("result where server_state = 4")); show_counts("Workunits waiting for validation", "workunits_waiting_for_validation", get_mysql_count("workunit where need_validate=1")); show_counts("Workunits waiting for assimilation", "workunits_waiting_for_assimilation", get_mysql_count("workunit where assimilate_state=1")); show_counts("Workunits waiting for deletion", "workunits_waiting_for_deletion", get_mysql_count("workunit where file_delete_state=1")); show_counts("Results waiting for deletion", "results_waiting_for_deletion", get_mysql_count("result where file_delete_state=1")); $result = mysql_query("select MIN(transition_time) as min from workunit"); $min = mysql_fetch_object($result); mysql_free_result($result); $gap = (time() - $min->min) / 3600; if ($gap < 0 || $min->min == 0) { $gap = 0; } show_counts("Transitioner backlog (hours)", "transitioner_backlog_hours", $gap); if (!$xml) { echo "</table>"; } } $xmlstring = " </database_file_states>\n</server_status>\n"; if ($xml) { echo $xmlstring;