2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
|
|
|
|
2004-11-01 23:10:02 +00:00
|
|
|
require_once("../inc/credit.inc");
|
|
|
|
|
2006-01-16 17:34:54 +00:00
|
|
|
function link_to_results($host) {
|
|
|
|
if (!$host) return "No host";
|
|
|
|
$config = get_config();
|
|
|
|
if (!parse_bool($config, "show_results")) return "Unavailable";
|
|
|
|
$nresults = host_nresults($host);
|
|
|
|
if (!$nresults) return "0";
|
|
|
|
return "<a href=results.php?hostid=$host->id>$nresults</a>";
|
|
|
|
}
|
|
|
|
|
2005-12-15 17:16:48 +00:00
|
|
|
function sched_log_name($x) {
|
|
|
|
if ($x == 0) return "NO_SUCH_LOG";
|
|
|
|
return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
|
|
|
|
}
|
|
|
|
|
|
|
|
function sched_log_link($x) {
|
|
|
|
return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>";
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
function location_form($host) {
|
2004-10-01 07:49:01 +00:00
|
|
|
$none = "selected";
|
2005-05-11 09:27:14 +00:00
|
|
|
$h=$w=$s="";
|
2004-02-02 23:34:39 +00:00
|
|
|
if ($host->venue == "home") $h = "selected";
|
|
|
|
if ($host->venue == "work") $w = "selected";
|
|
|
|
if ($host->venue == "school") $s = "selected";
|
|
|
|
$x = "<form action=host_venue_action.php>
|
|
|
|
<input type=hidden name=hostid value=$host->id>
|
|
|
|
<select name=venue>
|
2004-10-01 07:49:01 +00:00
|
|
|
<option value=\"\" $none>---
|
2004-02-02 23:34:39 +00:00
|
|
|
<option value=home $h>Home
|
|
|
|
<option value=work $w>Work
|
|
|
|
<option value=school $s>School
|
|
|
|
</select>
|
|
|
|
<input type=submit value=Update>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2007-01-29 18:15:16 +00:00
|
|
|
function show_host($host, $private, $ipprivate, $user) {
|
2004-02-02 23:34:39 +00:00
|
|
|
start_table();
|
|
|
|
row1("Computer information");
|
|
|
|
if ($private) {
|
|
|
|
if ($ipprivate) {
|
|
|
|
row2("IP address", "$host->last_ip_addr<br>(same the last $host->nsame_ip_addr times)");
|
2006-01-16 12:36:14 +00:00
|
|
|
if (strcmp($host->last_ip_addr, $host->external_ip_addr)) row2("External IP address", $host->external_ip_addr);
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
|
|
|
row2("IP address", "<a href=show_host_detail.php?hostid=$host->id&ipprivate=1>Show IP address</a>");
|
|
|
|
}
|
|
|
|
row2("Domain name", $host->domain_name);
|
2004-05-28 05:53:24 +00:00
|
|
|
$x = $host->timezone/3600;
|
2005-05-05 05:15:26 +00:00
|
|
|
if ($x >= 0) $x="+$x";
|
2005-05-05 05:06:16 +00:00
|
|
|
row2("Local Standard Time", "UTC $x hours");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
if ($private) {
|
|
|
|
row2("Name", $host->domain_name);
|
|
|
|
}
|
|
|
|
if (!$private) {
|
|
|
|
$user = lookup_user_id($host->userid);
|
|
|
|
if ($user && $user->show_hosts) {
|
|
|
|
row2("Owner", user_links($user));
|
|
|
|
} else {
|
|
|
|
row2("Owner", "Anonymous");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
row2("Created", time_str($host->create_time));
|
|
|
|
row2("Total Credit", format_credit($host->total_credit));
|
|
|
|
row2("Recent average credit", format_credit($host->expavg_credit));
|
2005-04-08 21:40:32 +00:00
|
|
|
row2("CPU type", "$host->p_vendor <br> $host->p_model");
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Number of CPUs", $host->p_ncpus);
|
2005-04-08 21:40:32 +00:00
|
|
|
row2("Operating System", "$host->os_name <br> $host->os_version");
|
2004-02-02 23:34:39 +00:00
|
|
|
$x = $host->m_nbytes/(1024*1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Memory", "$y MB");
|
|
|
|
$x = $host->m_cache/1024;
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Cache", "$y KB");
|
|
|
|
|
|
|
|
if ($private) {
|
|
|
|
$x = $host->m_swap/(1024*1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Swap space", "$y MB");
|
|
|
|
$x = $host->d_total/(1024*1024*1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Total disk space", "$y GB");
|
|
|
|
$x = $host->d_free/(1024*1024*1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Free Disk Space", "$y GB");
|
|
|
|
}
|
|
|
|
$x = $host->p_fpops/(1000*1000);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Measured floating point speed", "$y million ops/sec");
|
|
|
|
$x = $host->p_iops/(1000*1000);
|
|
|
|
$y = round($x, 2);
|
|
|
|
row2("Measured integer speed", "$y million ops/sec");
|
|
|
|
$x = $host->n_bwup/(1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
if ($y > 0) {
|
|
|
|
row2("Average upload rate", "$y KB/sec");
|
|
|
|
} else {
|
|
|
|
row2("Average upload rate", "Unknown");
|
|
|
|
}
|
|
|
|
$x = $host->n_bwdown/(1024);
|
|
|
|
$y = round($x, 2);
|
|
|
|
if ($y > 0) {
|
|
|
|
row2("Average download rate", "$y KB/sec");
|
|
|
|
} else {
|
|
|
|
row2("Average download rate", "Unknown");
|
|
|
|
}
|
2004-12-06 22:41:19 +00:00
|
|
|
$x = $host->avg_turnaround/86400;
|
2004-12-20 18:29:15 +00:00
|
|
|
row2("Average turnaround time", round($x, 2)." days");
|
2005-05-04 05:01:18 +00:00
|
|
|
$mrd= $host->max_results_day;
|
2005-05-11 08:29:35 +00:00
|
|
|
row2("Maximum daily WU quota per CPU", $mrd."/day");
|
2004-08-25 19:04:47 +00:00
|
|
|
$config = get_config();
|
2004-11-12 22:50:58 +00:00
|
|
|
if (parse_bool($config, "show_results")) {
|
2004-08-25 19:04:47 +00:00
|
|
|
$nresults = host_nresults($host);
|
|
|
|
if ($nresults) {
|
|
|
|
$results = "<a href=results.php?hostid=$host->id>$nresults</a>";
|
|
|
|
} else {
|
|
|
|
$results = "0";
|
|
|
|
}
|
|
|
|
row2("Results", $results);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($private) {
|
|
|
|
row2("Number of times client has contacted server", $host->rpc_seqno);
|
2005-12-15 17:16:48 +00:00
|
|
|
row2("Last time contacted server", sched_log_link($host->rpc_time));
|
2005-06-23 07:42:45 +00:00
|
|
|
row2("% of time BOINC client is running", 100*$host->on_frac." %");
|
2005-10-19 21:04:45 +00:00
|
|
|
if ($host->connect_frac > 0) {
|
|
|
|
row2("While BOINC running, % of time host has an Internet connection", 100*$host->connected_frac." %");
|
|
|
|
}
|
2005-06-23 07:42:45 +00:00
|
|
|
row2("While BOINC running, % of time work is allowed", 100*$host->active_frac." %");
|
|
|
|
if ($host->cpu_efficiency) {
|
|
|
|
row2("Average CPU efficiency", $host->cpu_efficiency);
|
|
|
|
}
|
|
|
|
if ($host->duration_correction_factor) {
|
|
|
|
row2("Result duration correction factor", $host->duration_correction_factor);
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Location", location_form($host));
|
|
|
|
if ($nresults == 0) {
|
2007-01-29 18:15:16 +00:00
|
|
|
$x = " | <a href=host_delete.php?hostid=$host->id".url_tokens($user->authenticator).">Delete this host</a> ";
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
|
|
|
$x = "";
|
|
|
|
}
|
2004-05-30 21:47:11 +00:00
|
|
|
row2("Click to", "<a href=host_edit_form.php?hostid=$host->id>merge this computer</a> $x");
|
2004-07-02 19:17:53 +00:00
|
|
|
//row2("Click to", "<a href=host_update_credit.php?hostid=$host->id>recompute credit</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-05-31 00:50:06 +00:00
|
|
|
// the following is used for list of top hosts
|
|
|
|
//
|
|
|
|
function top_host_table_start($sort_by) {
|
|
|
|
start_table();
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<th>Computer ID<br><font size=-2>Click for more info</font></th>\n";
|
|
|
|
echo "<th>Rank</th>";
|
|
|
|
echo "<th>Owner</th>\n";
|
|
|
|
if ($sort_by == 'total_credit') {
|
|
|
|
echo "
|
2004-08-04 15:30:52 +00:00
|
|
|
<th><a href=top_hosts.php?sort_by=expavg_credit>Recent average credit</a></th>
|
2004-05-31 00:50:06 +00:00
|
|
|
<th>Total credit</th>
|
|
|
|
";
|
|
|
|
} else {
|
|
|
|
echo "
|
|
|
|
<th>Recent average credit</th>
|
2004-08-04 15:30:52 +00:00
|
|
|
<th><a href=top_hosts.php?sort_by=total_credit>Total credit</a></th>
|
2004-05-31 00:50:06 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
echo "
|
|
|
|
<th>CPU type</th>
|
|
|
|
<th>Operating system</th>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
function host_nresults($host) {
|
|
|
|
$result = mysql_query("select count(*) as nresults from result where hostid=$host->id");
|
|
|
|
$foobar = mysql_fetch_object($result);
|
|
|
|
return $foobar->nresults;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If private is true, we're showing the host to its owner,
|
|
|
|
// so it's OK to show the domain name etc.
|
|
|
|
// If private is false, show the owner's name only if they've given permission
|
|
|
|
//
|
|
|
|
function show_host_row($host, $i, $private, $show_owner) {
|
|
|
|
$result = mysql_query("select * from user where id = $host->userid");
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
|
2004-02-05 21:35:48 +00:00
|
|
|
echo "<tr><td>", host_link($host->id), "</td>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
if ($private) {
|
|
|
|
echo "<td> $host->domain_name";
|
|
|
|
} else {
|
|
|
|
echo "<td>$i</td>\n
|
|
|
|
";
|
|
|
|
if ($show_owner) {
|
|
|
|
if ($user->show_hosts) {
|
|
|
|
echo "<td>", user_links($user), "</td>\n";
|
|
|
|
} else {
|
|
|
|
echo "<td>Anonymous</td>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-16 17:34:54 +00:00
|
|
|
if ($show_owner) {
|
|
|
|
// This is used in the TOP COMPUTERS display
|
|
|
|
//
|
|
|
|
printf("
|
|
|
|
<td>%s</td>
|
|
|
|
<td>%s</td>
|
|
|
|
<td>%s <br> %s</td>
|
|
|
|
<td>%s <br> %s</td>",
|
|
|
|
format_credit($host->expavg_credit), format_credit($host->total_credit),
|
|
|
|
$host->p_vendor, $host->p_model,
|
|
|
|
$host->os_name, $host->os_version
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// This is used in constructing list of COMPUTERS for a given user
|
|
|
|
//
|
|
|
|
$config = get_config();
|
|
|
|
if (parse_bool($config, "show_results")) {
|
|
|
|
$ltr="<td>".link_to_results($host)."</td>";
|
|
|
|
} else {
|
|
|
|
$ltr="";
|
|
|
|
}
|
|
|
|
printf("
|
|
|
|
<td>%s</td>
|
|
|
|
<td>%s</td>
|
|
|
|
<td>%s <br> %s</td>
|
|
|
|
<td>%s <br> %s</td>
|
|
|
|
%s
|
|
|
|
<td>%s</td>",
|
|
|
|
format_credit($host->expavg_credit), format_credit($host->total_credit),
|
|
|
|
$host->p_vendor, $host->p_model,
|
|
|
|
$host->os_name, $host->os_version, $ltr, sched_log_link($host->rpc_time)
|
|
|
|
);
|
|
|
|
}
|
2005-07-21 06:57:40 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
//$nresults = host_nresults($host);
|
|
|
|
//echo "<td><a href=results.php?hostid=$host->id>$nresults</a></td>";
|
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// return true iff it's possible that the hosts are actually
|
|
|
|
// the same machine
|
|
|
|
//
|
2005-04-08 21:40:32 +00:00
|
|
|
function ghz($x) {
|
|
|
|
$y = explode(" ", $x);
|
|
|
|
foreach ($y as $z) {
|
|
|
|
if (strstr($z, "GHz")) return $z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-23 07:11:23 +00:00
|
|
|
// return true if it's possible that the two host records
|
|
|
|
// correspond to the same host
|
|
|
|
//
|
2004-02-02 23:34:39 +00:00
|
|
|
function hosts_compatible($host1, $host2) {
|
2005-04-08 21:40:32 +00:00
|
|
|
// we screwed around with Intel processor names,
|
|
|
|
// so count them as compatible if both contain "Intel" and "Pentium",
|
|
|
|
// and don't have conflicting clock rate info
|
2007-02-19 18:37:00 +00:00
|
|
|
|
2005-04-08 21:40:32 +00:00
|
|
|
$p1 = "$host1->p_vendor $host1->p_model";
|
|
|
|
$p2 = "$host2->p_vendor $host2->p_model";
|
|
|
|
if (strstr($p1, "Pentium") && strstr($p1, "Intel")
|
|
|
|
&& strstr($p2, "Pentium") && strstr($p2, "Intel")
|
|
|
|
) {
|
|
|
|
$g1 = ghz($p1);
|
|
|
|
$g2 = ghz($p2);
|
2007-02-19 18:37:00 +00:00
|
|
|
if ($g1 && $g2) {
|
|
|
|
if ($g1 != $g2) return false;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2005-04-08 21:40:32 +00:00
|
|
|
} else {
|
|
|
|
if ($host2->p_vendor != $host1->p_vendor) return false;
|
2007-02-19 18:37:00 +00:00
|
|
|
$pos = strpos($host1->p_model, '[');
|
|
|
|
$host1pm = $host1->p_model;
|
|
|
|
if($pos !== FALSE) {
|
|
|
|
$host1pm = trim(substr($host1->p_model, 0, $pos));
|
|
|
|
}
|
|
|
|
$pos = strpos($host2->p_model, '[');
|
|
|
|
$host2pm = $host2->p_model;
|
|
|
|
if($pos !== FALSE) {
|
|
|
|
$host2pm = trim(substr($host2->p_model, 0, $pos));
|
|
|
|
}
|
|
|
|
if($host2pm != $host1pm) return false;
|
2005-04-08 21:40:32 +00:00
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
if ($host2->os_name != $host1->os_name) return false;
|
2005-10-23 07:11:23 +00:00
|
|
|
|
2007-02-19 18:37:00 +00:00
|
|
|
// one host must strictly precede the other
|
|
|
|
if ($host1->rpc_time < $host2->create_time) return true;
|
|
|
|
if ($host2->rpc_time < $host1->create_time) return true;
|
2005-10-23 07:11:23 +00:00
|
|
|
return false;
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2004-11-01 23:10:02 +00:00
|
|
|
// recompute host's average credit by scanning results.
|
|
|
|
// Could be expensive if lots of results!
|
|
|
|
//
|
2004-06-01 18:55:59 +00:00
|
|
|
function host_update_credit($hostid) {
|
2004-11-01 23:10:02 +00:00
|
|
|
$total = 0;
|
2004-06-01 18:55:59 +00:00
|
|
|
$avg = 0;
|
|
|
|
$avg_time = 0;
|
|
|
|
$r = mysql_query("select * from result where hostid=$hostid order by received_time");
|
|
|
|
while ($result = mysql_fetch_object($r)) {
|
|
|
|
if ($result->granted_credit <= 0) continue;
|
2004-11-01 23:10:02 +00:00
|
|
|
$total += $result->granted_credit;
|
|
|
|
|
|
|
|
update_average(
|
|
|
|
$result->received_time,
|
|
|
|
$result->sent_time,
|
|
|
|
$result->granted_credit,
|
|
|
|
$avg,
|
|
|
|
$avg_time
|
|
|
|
);
|
2004-06-01 18:55:59 +00:00
|
|
|
|
|
|
|
echo "<br>$avg\n";
|
|
|
|
}
|
|
|
|
mysql_free_result($r);
|
|
|
|
|
2004-11-01 23:10:02 +00:00
|
|
|
// do a final decay
|
|
|
|
//
|
|
|
|
$now = time();
|
|
|
|
update_average(now, 0, 0, $avg, $avg_time);
|
|
|
|
|
|
|
|
mysql_query("update host set total_credit=$total, expavg_credit=$avg, expavg_time=$now where id=$hostid");
|
|
|
|
}
|
|
|
|
|
|
|
|
// decay a host's average credit
|
|
|
|
//
|
|
|
|
function host_decay_credit($host) {
|
|
|
|
$avg = $host->expavg_credit;
|
|
|
|
$avg_time = $host->expavg_time;
|
|
|
|
$now = time(0);
|
|
|
|
update_average($now, 0, 0, $avg, $avg_time);
|
|
|
|
mysql_query("update host set expavg_credit=$avg, expavg_time=$now where id=$host->id");
|
|
|
|
|
|
|
|
}
|
|
|
|
// if the host hasn't received new credit for ndays,
|
|
|
|
// decay its average and return true
|
|
|
|
//
|
|
|
|
function host_inactive_ndays($host, $ndays) {
|
|
|
|
$diff = time() - $host->expavg_time;
|
|
|
|
if ($diff > $ndays*86400) {
|
|
|
|
host_decay_credit($host);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2004-06-01 18:55:59 +00:00
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|