function show_stats($brand) { switch ($brand) { case 1: $x = "HTC Power to Give"; break; default: error_page("invalid brand"); } $hosts = BoincHost::enum("os_name='Android' and serialnum like '%{$x}%'"); $n = 0; $t = 0; $a = 0; foreach ($hosts as $h) { $t += $h->total_credit; $a += $h->expavg_credit; if ($h->expavg_credit > 0.1) { $n++; } } page_head("Stats for {$x}"); start_table(); row2("Active devices", $n); row2("Average daily credit", $a); row2("Total credit", $t); end_table(); page_tail(); }
function get_host($hostid, $user) { $host = BoincHost::lookup_id($hostid); if (!$host || $host->userid != $user->id) { fail("We have no record of that computer"); } return $host; }
function get_gpu_list($vendor, $alt_vendor = null) { $clause = "plan_class like '%{$vendor}%'"; if ($alt_vendor) { $clause .= " or plan_class like '%{$alt_vendor}%'"; } $avs = BoincAppVersion::enum($clause); if (count($avs) == 0) { return null; } $av_ids = ""; foreach ($avs as $av) { $av_ids .= "{$av->id}, "; } $av_ids .= "0"; $t = time() - 30 * 86400; //echo "start enum $vendor $av_ids\n"; $results = BoincResult::enum("app_version_id in ({$av_ids}) and create_time > {$t} and elapsed_time>100 limit 500"); //echo "end enum\n"; $total = array(); $win = array(); $linux = array(); $mac = array(); foreach ($results as $r) { $h = BoincHost::lookup_id($r->hostid); if (!$h) { continue; } $wu = BoincWorkunit::lookup_id($r->workunitid); if (!$wu) { continue; } $v = $vendor == "cuda" ? "CUDA" : "CAL"; $model = get_gpu_model($h->serialnum, $v); if (!$model) { continue; } add_model($model, $r, $wu, $total); if (strstr($h->os_name, "Windows")) { add_model($model, $r, $wu, $win); } if (strstr($h->os_name, "Linux")) { add_model($model, $r, $wu, $linux); } if (strstr($h->os_name, "Darwin")) { add_model($model, $r, $wu, $mac); } } $x = null; $x->total = $total; $x->win = $win; $x->linux = $linux; $x->mac = $mac; return $x; }
function merge_by_name($userid) { $hosts = array(); $host_list = BoincHost::enum("userid={$userid}"); foreach ($host_list as $host) { $hosts[$host->domain_name][] = $host; } foreach ($hosts as $hlist) { merge_name($hlist); } }
function get_top_hosts($offset, $sort_by) { global $hosts_per_page; $db = BoincDb::get(true); if ($sort_by == "total_credit") { $sort_order = "total_credit desc"; } else { $sort_order = "expavg_credit desc"; } return BoincHost::enum(null, "order by {$sort_order} limit {$offset}, {$hosts_per_page}"); }
function get_cpu_list() { $models = array(); $hosts = BoincHost::enum("expavg_credit >= " . MIN_CREDIT); foreach ($hosts as $host) { $x = new StdClass(); $x->p_ncpus = $host->p_ncpus; $x->p_fpops = $host->p_fpops; if (!array_key_exists($host->p_model, $models)) { $models[$host->p_model] = array(); } $models[$host->p_model][] = $x; } // for each model, find the median FLOPS $m2 = array(); foreach ($models as $model => $list) { $n = sizeof($list); if ($n < MIN_COUNT) { continue; } uasort($list, 'compare'); $m = (int) ($n / 2); $total_cores = 0; foreach ($list as $l) { $total_cores += $l->p_ncpus; } $x = $list[$m]->p_fpops; $y = new StdClass(); $y->model = $model; $y->p_fpops = $x; $y->mean_ncores = $total_cores / $n; $y->nhosts = $n; $m2[] = $y; //echo "$model: $x GFLOPS ($n samples)\n"; } uasort($m2, 'compare'); $x = new StdClass(); $x->cpus = $m2; $x->time = time(); return $x; foreach ($m2 as $x) { $g = $x->p_fpops / 1000000000.0; echo "{$x->model}: {$g} gflops {$x->mean_ncores} cores {$x->nhosts} hosts \n"; } }
$host_content .= "\n Total Disk Space: {$y} GB"; $x = $host->d_free / (1024 * 1024 * 1024); $y = round($x, 2); $host_content .= "\n Free Disk Space: {$y} GB\n Avg network bandwidth (upstream): {$host->n_bwup} bytes/sec\n Avg network bandwidth (downstream): {$host->n_bwdown} bytes/sec"; $x = $host->avg_turnaround / 86400; $host_content .= "\n Average turnaround: " . round($x, 2) . " days\n Number of RPCs: {$host->rpc_seqno}\n Last RPC: " . time_str($host->rpc_time) . "\n % of time client on: " . 100 * $host->on_frac . " %\n % of time host connected: " . 100 * $host->connected_frac . " %\n % of time user active: " . 100 * $host->active_frac . " %\n # of results today: " . $host->nresults_today; $subject = PROJECT . " notice for {$user->name}"; $body = PROJECT . " notification:\n\nDear {$user->name}\nYour machine (host # {$host->id}) described below appears to have a misconfigured BOINC\ninstallation. Could you please have a look at it?\n\nSincerely,\n The " . PROJECT . " team\n"; $body .= "\n\nThis is the content of our database:\n" . $host_content . "\n\nFor further information and assistance with " . PROJECT . " go to {$master_url}"; echo nl2br($body) . "<br><br>"; return send_email($user, $subject, $body); } $hostid = get_int("hostid", true); if (!$hostid) { admin_page_head("Misconfigured Host"); echo "This script sends an email to the owner of the supplied host which says that something gone wrong with his configuration.<br>"; echo "<br><form method=\"get\" action=\"problem_host.php\">\n Host ID: \n <input type=\"text\" size=\"5\" name=\"hostid\">\n <input class=\"btn btn-default\" type=\"submit\" value=\"Send Email\">\n </form>\n "; } else { $host = BoincHost::lookup_id($hostid); if (!$host) { echo "<h2>No host with that ID</h2>\n\t \t<center>Please <a href=\"problem_host.php\">try again</a></center>"; } else { $user = BoincUser::lookup_id($host->userid); echo "<a href=\"problem_host.php\">Do another?</a><br><br>"; send_problem_email($user, $host); echo "Email to " . $user->email_addr . " has been sent.<br>"; } } admin_page_tail(); $cvs_version_tracker[] = "\$Id\$"; //Generated automatically - do not edit
function get_data() { $nwus = 4000; $sum = array(); for ($i = 0; $i <= 10; $i++) { $sum[] = 0; } $r1 = _mysql_query("select id from workunit where canonical_resultid>0 limit {$nwus}"); $n = 0; while ($wu = _mysql_fetch_object($r1)) { $results = array(); $r2 = _mysql_query("select * from result where workunitid={$wu->id}"); $found_zero = false; while ($result = _mysql_fetch_object($r2)) { if ($result->granted_credit == 0) { continue; } // skip invalid $host = BoincHost::lookup_id($result->hostid); $r = new StdClass(); $r->cpu_time = $result->cpu_time; $r->p_fpops = $host->p_fpops; $r->p_iops = $host->p_iops; $results[] = $r; } //echo "Wu $wu->id -------------\n"; if (count($results) < 2) { continue; } for ($i = 0; $i <= 10; $i++) { $fpw = $i / 10.0; $sum[$i] += fpw_var($results, $fpw); } $n++; } echo "This script recommends value for <fp_benchmark_weight> in config.xml.\nIt does this by finding the value that minimizes the variance\namong claimed credit for workunits currently in your database.\nIt examines at most {$nwus} WUs (edit the script to change this).\n\nNumber of workunits analyzed: {$n}\n\n"; for ($i = 0; $i <= 10; $i++) { $fpw = $i / 10.0; $r = $sum[$i] / $n; echo "FP weight {$fpw}: variance is {$r}\n"; if ($i == 0) { $best = $r; $fbest = $fpw; } else { if ($r < $best) { $best = $r; $fbest = $fpw; } } } echo "\nRecommended value: {$fbest}\n"; }
function get_job_status() { $s = unserialize(get_cached_data(STATUS_PAGE_TTL, "job_status")); if ($s) { return $s; } $s = new StdClass(); $apps = BoincApp::enum("deprecated=0"); foreach ($apps as $app) { $info = BoincDB::get()->lookup_fields("result", "stdClass", "ceil(avg(elapsed_time)/3600*100)/100 as avg,\n ceil(min(elapsed_time)/3600*100)/100 as min,\n ceil(max(elapsed_time)/3600*100)/100 as max,\n count(distinct userid) as users", "appid = {$app->id}\n AND validate_state=1\n AND received_time > (unix_timestamp()-86400)\n "); $app->info = $info; $app->unsent = BoincResult::count("appid={$app->id} and server_state=2"); $app->in_progress = BoincResult::count("appid={$app->id} and server_state=4"); } $s->apps = $apps; $s->results_ready_to_send = BoincResult::count("server_state=2"); $s->results_in_progress = BoincResult::count("server_state=4"); $s->results_need_file_delete = BoincResult::count("file_delete_state=1"); $s->wus_need_validate = BoincWorkunit::count("need_validate=1"); $s->wus_need_assimilate = BoincWorkunit::count("assimilate_state=1"); $s->wus_need_file_delete = BoincWorkunit::count("file_delete_state=1"); $x = BoincDB::get()->lookup_fields("workunit", "stdClass", "MIN(transition_time) as min", "TRUE"); $gap = (time() - $x->min) / 3600; if ($gap < 0 || $x->min == 0) { $gap = 0; } $s->transitioner_backlog = $gap; $s->users_with_recent_credit = BoincUser::count("expavg_credit>1"); $s->users_with_credit = BoincUser::count("total_credit>1"); $s->users_past_24_hours = BoincUser::count("create_time > (unix_timestamp() - 86400)"); $s->hosts_with_recent_credit = BoincHost::count("expavg_credit>1"); $s->hosts_with_credit = BoincHost::count("total_credit>1"); $s->hosts_past_24_hours = BoincHost::count("create_time > (unix_timestamp() - 86400)"); $s->flops = BoincUser::sum("expavg_credit") / 200; $s->db_revision = null; if (file_exists("../../db_revision")) { $s->db_revision = trim(file_get_contents("../../db_revision")); } $s->cached_time = time(); $e = set_cached_data(STATUS_PAGE_TTL, serialize($s), "job_status"); if ($e) { echo "set_cached_data(): {$e}\n"; } return $s; }
function estimated_makespan($njobs, $flops_per_job) { $nhosts = BoincHost::count("expavg_credit > 1"); if ($nhosts < 10) { $median_flops = 2000000000.0; } else { $n = (int) ($nhosts / 2); $hs = BoincHost::enum("expavg_credit>1 order by p_fpops limit {$n},1"); $h = $hs[0]; $median_flops = $h->p_fpops; } if ($njobs < $nhosts) { return $flops_per_job / $median_flops; } else { $k = (int) (($njobs + $nhosts - 1) / $nhosts); return $k * $flops_per_job / $median_flops; } }
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. require_once "../inc/boinc_db.inc"; require_once "../inc/util.inc"; require_once "../inc/host.inc"; check_get_args(array("hostid", "detail")); $user = get_logged_in_user(); $hostid = get_int("hostid"); $host = BoincHost::lookup_id($hostid); if (!$host || $host->userid != $user->id) { error_page("We have no record of that computer"); } $detail = get_int('detail', true); page_head(tra("Merge computers")); $t = time_str($host->create_time); echo tra("Sometimes BOINC assigns separate identities to the same computer by mistake. You can correct this by merging old identities with the newest one.") . "\n <form name=host_list action=host_edit_action.php>\n <input type=hidden name=id_0 value={$hostid}>\n <p>\n"; $all_hosts = BoincHost::enum("userid={$user->id}"); $nhosts = 1; $hosts = array(); foreach ($all_hosts as $host2) { if ($host->id == $host2->id) { continue; } if (!hosts_compatible($host, $host2, $detail)) { continue; } $hosts[] = $host2; $nhosts++; if ($nhosts == 500) { break; } }
function delete_teams() { global $days, $test; $query = "nusers < 2 and seti_id=0 and total_credit=0"; if ($days) { $x = time() - $days * 86400; $query .= " and create_time > {$x}"; } $teams = BoincTeam::enum($query); foreach ($teams as $team) { $n = team_count_members($team->id); if ($n > 1) { continue; } if (!has_link($team->description)) { continue; } $user = BoincUser::lookup_id($team->userid); if ($user) { $n = BoincPost::count("user={$user->id}"); if ($n) { continue; } $n = BoincHost::count("userid={$user->id}"); if ($n) { continue; } } if ($test) { echo "would delete team:\n"; echo " ID: {$team->id}\n"; echo " name: {$team->name}\n"; echo " description: {$team->description}\n"; } else { $team->delete(); echo "deleted team ID {$team->id} name {$team->name}\n"; if ($user) { do_delete_user($user); } } } }
exit; } $private = false; } else { $user = get_logged_in_user(); $caching = false; $userid = $user->id; page_head("Your computers"); more_or_less($sort, $rev, $show_all); user_host_table_start(true, $sort, $rev, $show_all); $private = true; } $now = time(); $old_hosts = 0; $i = 1; $hosts = BoincHost::enum("userid={$userid} order by {$sort_clause}"); foreach ($hosts as $host) { $is_old = false; if ($now - $host->rpc_time > 30 * 86400) { $is_old = true; $old_hosts++; } if (!$show_all && $is_old) { continue; } show_host_row($host, $i, $private, false); $i++; } echo "</table>\n"; if ($old_hosts > 0) { more_or_less($sort, $rev, $show_all);
function analyze_all() { $total = 0; $nnv = 0; $nati = 0; $nboth = 0; $hosts = BoincHost::enum("expavg_credit > 10 and serialnum<>''"); foreach ($hosts as $host) { $boinc_vers = parse_vers($host->serialnum); if (!$boinc_vers) { continue; } if ($boinc_vers->major < 6) { continue; } if ($boinc_vers->major == 6 && $boinc_vers->minor < 10) { continue; } $total++; $has_nv = strstr($host->serialnum, 'CUDA'); $has_ati = strstr($host->serialnum, 'ATI'); if ($has_nv) { $nnv++; } if ($has_ati) { $nati++; } if ($has_nv && $has_ati) { $nboth++; } } echo "total: {$total} NVIDIA: {$nnv} ATI: {$nati} both: {$nboth}\n"; }
function delete_profiles() { global $test, $days; $profiles = BoincProfile::enum(""); foreach ($profiles as $p) { if (has_link($p->response1) || has_link($p->response2)) { $user = BoincUser::lookup_id($p->userid); if (!$user) { echo "profile has missing user: %p->userid\n"; continue; } if ($days) { if ($user->create_time < time() - $days * 86400) { continue; } } $n = BoincHost::count("userid={$p->userid}"); if ($n) { continue; } $n = BoincPost::count("user={$p->userid}"); if ($n) { continue; } delete_user($user); if ($test) { echo "\n{$p->userid}\n{$p->response1}\n{$p->response2}\n"; } } } }