2002-12-06 21:37:30 +00:00
|
|
|
<?php
|
|
|
|
require_once("util.inc");
|
|
|
|
require_once("user.inc");
|
|
|
|
require_once("db.inc");
|
|
|
|
require_once("user.inc");
|
|
|
|
|
2003-03-06 00:42:18 +00:00
|
|
|
function location_form($host) {
|
|
|
|
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>
|
|
|
|
<option value=home $h>Home
|
|
|
|
<option value=work $w>Work
|
|
|
|
<option value=school $s>School
|
|
|
|
</select>
|
|
|
|
<input type=submit value=Update>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
return $x;
|
|
|
|
}
|
2002-12-06 21:37:30 +00:00
|
|
|
|
2003-03-06 00:42:18 +00:00
|
|
|
function show_host($host) {
|
|
|
|
start_table();
|
|
|
|
row1("Host Information");
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("IP address", "$host->last_ip_addr<br>(same the last $host->nsame_ip_addr times)");
|
|
|
|
row2("Domain name", $host->domain_name);
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->timezone/3600;
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Time zone", "UTC - $x hours");
|
|
|
|
row2("Created", time_str($host->create_time));
|
|
|
|
row2("Total Credit", $host->total_credit);
|
|
|
|
row2("Recent average credit", $host->expavg_credit);
|
|
|
|
row2("CPU type", "$host->p_vendor $host->p_model");
|
|
|
|
row2("Number of CPUs", $host->p_ncpus);
|
|
|
|
row2("Operating System", "$host->os_name $host->os_version");
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->m_nbytes/(1024*1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Memory", "$y MB");
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->m_cache/1024;
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Cache", "$y KB");
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->m_swap/(1024*1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Swap space", "$y MB");
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->d_total/(1024*1024*1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Total disk space", "$y GB");
|
2002-12-06 21:37:30 +00:00
|
|
|
$x = $host->d_free/(1024*1024*1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Free Disk Space", "$y GB");
|
2002-12-18 20:37:42 +00:00
|
|
|
$x = $host->p_fpops/(1000*1000);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Measured floating point speed", "$y million ops/sec");
|
2002-12-18 20:37:42 +00:00
|
|
|
$x = $host->p_iops/(1000*1000);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Measured integer speed", "$y million ops/sec");
|
2002-12-18 20:37:42 +00:00
|
|
|
$x = $host->p_membw/(1024*1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Measured memory bandwidth", "$y MB/sec");
|
2002-12-18 20:37:42 +00:00
|
|
|
$x = $host->n_bwup/(1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
if ($y > 0) {
|
2003-03-06 00:42:18 +00:00
|
|
|
row2("Average upload rate", "$y KB/sec");
|
2003-02-27 22:30:31 +00:00
|
|
|
} else {
|
2003-03-06 00:42:18 +00:00
|
|
|
row2("Average upload rate", "Unknown");
|
2003-02-27 22:30:31 +00:00
|
|
|
}
|
2002-12-18 20:37:42 +00:00
|
|
|
$x = $host->n_bwdown/(1024);
|
|
|
|
$y = round($x, 2);
|
2003-02-27 22:30:31 +00:00
|
|
|
if ($y > 0) {
|
2003-03-06 00:42:18 +00:00
|
|
|
row2("Average download rate", "$y KB/sec");
|
2003-02-27 22:30:31 +00:00
|
|
|
} else {
|
2003-03-06 00:42:18 +00:00
|
|
|
row2("Average download rate", "Unknown");
|
2003-02-27 22:30:31 +00:00
|
|
|
}
|
|
|
|
row2("Number of times client has contacted server", $host->rpc_seqno);
|
|
|
|
row2("Last time contacted server", time_str($host->rpc_time));
|
2003-03-06 00:42:18 +00:00
|
|
|
row2("% of time client is on", 100*$host->on_frac." %");
|
|
|
|
row2("% of time host is connected", 100*$host->connected_frac." %");
|
|
|
|
row2("% of time user is active", 100*$host->active_frac." %");
|
|
|
|
row2("Location", location_form($host));
|
2002-12-06 21:37:30 +00:00
|
|
|
echo "</table>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
$authenticator = init_session();
|
|
|
|
db_init();
|
|
|
|
$user = get_user_from_auth($authenticator);
|
|
|
|
$hostid = $HTTP_GET_VARS["hostid"];
|
|
|
|
if ($user && $hostid) {
|
|
|
|
page_head("Host stats");
|
|
|
|
|
2003-01-03 21:55:05 +00:00
|
|
|
$result = mysql_query("select * from host where id = $hostid");
|
2002-12-06 21:37:30 +00:00
|
|
|
$host = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
|
|
|
|
if ($host) {
|
2003-01-03 21:55:05 +00:00
|
|
|
if ($host->userid != $user->id) {
|
|
|
|
echo "Not your host\n";
|
|
|
|
} else {
|
|
|
|
show_host($host);
|
|
|
|
}
|
2002-12-06 21:37:30 +00:00
|
|
|
} else {
|
|
|
|
echo "Couldn't find host or user.<p>";
|
|
|
|
}
|
|
|
|
page_tail();
|
|
|
|
} else {
|
|
|
|
print_login_form();
|
|
|
|
}
|
|
|
|
?>
|