web DB interface

svn path=/trunk/boinc/; revision=1627
This commit is contained in:
David Anderson 2003-07-01 18:28:33 +00:00
parent 1bcc18038f
commit 3962777cbf
5 changed files with 149 additions and 68 deletions

View File

@ -5168,3 +5168,12 @@ David June 30 2003
index.php
result_summary.php
util.inc
David July 1 2003
- further tweaks to web DB interface
html_ops/
db.inc
db_action.php
db_form.php
index.php

View File

@ -104,14 +104,14 @@ function show_app($app) {
end_table();
}
function show_app_version($app_version,$show_xml_docs) {
function show_app_version($app_version, $hide_xml_docs) {
start_table();
row("ID", $app_version->id);
row("Created", time_str($app_version->create_time));
row("Application", "<a href=db_action.php?table=app&id=$app_version->appid>" . app_name_by_id($app_version->appid) . "</a>");
row("Version num", $app_version->version_num);
row("Platform", "<a href=db_action.php?table=platform&id=$app_version->platformid>" . platform_name_by_id($app_version->platformid) . "</a>" );
if ($show_xml_docs) {
if (!$hide_xml_docs) {
row("XML doc", "<pre>".htmlspecialchars($app_version->xml_doc)."</pre>");
}
row("Min_core_version", $app_version->min_core_version);
@ -121,9 +121,34 @@ function show_app_version($app_version,$show_xml_docs) {
end_table();
}
function host_short_header() {
echo "
<tr>
<th>host ID</th>
<th>IP address</th>
<th>name</th>
<th>CPU</th>
<th>OS</th>
</tr>
";
}
function show_host_short($host) {
echo "
<tr>
<td><a href=db_action?table=host&id=$host->id>$host->id</a></td>
<td>$host->last_ip_addr</td>
<td>$host->domain_name</td>
<td>$host->p_vendor $host->p_model</td>
<td>$host->os_name $host->os_version</td>
</tr>
";
}
function show_host($host) {
start_table();
row("ID", $host->id);
row("Created", time_str($host->create_time));
row("Venue", $host->venue);
row("Total credit", $host->total_credit);
@ -161,7 +186,7 @@ function show_host($host) {
row("% of time client on", 100*$host->on_frac." %");
row("% of time host connected", 100*$host->connected_frac." %");
row("% of time user active", 100*$host->active_frac." %");
row("Results", "<a href=db_action?table=result&detail=low&hostid=$host->id>click here</a>");
row("Results", "<a href=db_action?table=result&detail=low&hostid=$host->id&sort_by=sent_time>click here</a>");
end_table();
}
@ -191,11 +216,11 @@ function file_delete_state_str($s) {
}
}
function show_workunit($wu,$show_xml_doc) {
function show_workunit($wu, $hide_xml_doc) {
start_table();
row("Created", time_str($wu->create_time));
row("Name", $wu->name);
if ($show_xml_doc) {
if (!$hide_xml_doc) {
row("XML doc", "<pre>".htmlspecialchars($wu->xml_doc)."</pre>");
}
row("Application", "<a href=db_action.php?table=app&id=$wu->appid>" . app_name_by_id($wu->appid) . "</a>");
@ -260,9 +285,9 @@ function validate_state_str($s) {
return "Unknown";
}
function show_result($result,$show_xml_docs,$show_stderr,$show_times) {
function show_result($result, $hide_xml_docs, $hide_stderr, $hide_times) {
start_table();
if ($show_times) {
if (!$hide_times) {
row("Created", time_str($result->create_time));
row("Sent", time_str($result->sent_time));
row("Received", time_str($result->received_time));
@ -275,11 +300,11 @@ function show_result($result,$show_xml_docs,$show_stderr,$show_times) {
row("Host ID", "<a href=db_action.php?table=host&id=$result->hostid>" . host_name_by_id($result->hostid) . "</a>");
row("Report deadline", time_str($result->report_deadline));
row("CPU time", $result->cpu_time);
if ($show_xml_docs) {
if (!$hide_xml_docs) {
row("XML doc in", "<pre>".htmlspecialchars($result->xml_doc_in)."</pre>");
row("XML doc out", "<pre>".htmlspecialchars($result->xml_doc_out)."</pre>");
}
if ($show_stderr) {
if (!$hide_stderr) {
row("stderr out", "<pre>".htmlspecialchars($result->stderr_out)."</pre>");
}
row("Batch", $result->batch);
@ -294,7 +319,7 @@ function show_result($result,$show_xml_docs,$show_stderr,$show_times) {
function result_short_header() {
echo "
<tr>
<th>ID</th>
<th>result ID</th>
<th>WU ID</th>
<th>server state</th>
<th>outcome</th>
@ -315,13 +340,22 @@ function show_result_short($result) {
<td>$ss</td>
<td>$oc</td>
<td>$cs</td>
<td><a href=db_action.php?table=host&id=$result->hostid>$result->hostid</a></td>
";
if ($result->hostid) {
echo "
<td><a href=db_action.php?table=host&id=$result->hostid>$result->hostid</a></td>
";
} else {
echo "<td>---</td>\n";
}
echo "
</tr>
";
}
function show_user($user) {
start_table();
row("ID", $user->id);
row("Created", time_str($user->create_time));
row("Name", $user->name);
row("Authenticator", $user->authenticator);
@ -331,7 +365,8 @@ function show_user($user) {
row("Total credit", $user->total_credit);
row("Average credit", $user->expavg_credit);
row("Last average time", time_str($user->expavg_time));
row("Venue", $user->venue);
row("Default venue", $user->venue);
row("Hosts", "<a href=db_action?table=host&userid=$user->id&detail=low>click</a>");
end_table();
}

View File

@ -16,6 +16,11 @@ function append_sql_query($original,$addition,$first) {
$first = 1;
if (strlen($clauses)) {
$query = append_sql_query( $query, $clauses, $first );
$first = 0;
}
if (strlen($id)) {
$query = append_sql_query( $query, "id = $id", $first );
$first = 0;
@ -41,6 +46,11 @@ function append_sql_query($original,$addition,$first) {
$first = 0;
}
if (strlen($userid)) {
$query = append_sql_query( $query, "userid = $userid", $first );
$first = 0;
}
if (strlen($team_id)) {
$query = append_sql_query( $query, "teamid = $team_id", $first );
$first = 0;
@ -103,7 +113,7 @@ function append_sql_query($original,$addition,$first) {
$main_query = "select * from ".$table." ".$query. " limit ".$entries_to_show;
}
echo "<p>Query is: <b>$main_query</b><p>\n";
echo "<p>Query: <b>$main_query</b><p>\n";
echo "
<p>$count database entries match the query.
Displaying $start_at to $last.<p>
@ -112,25 +122,47 @@ function append_sql_query($original,$addition,$first) {
$urlquery = urlencode($query);
if ($last < $count) {
echo "
<a href=db_action.php?table=$table&query=$urlquery&last_pos=$last>Next $n</a>
<a href=db_action.php?table=$table&query=$urlquery&last_pos=$last&detail=$detail>Next $entries_to_show</a>
";
}
if ($detail == "high") {
echo "
<a href=db_action.php?table=$table&query=$urlquery&detail=low>Single-line</a>
| <a href=db_action.php?table=$table&query=$urlquery&detail=low>Less detail</a>
";
}
if ($detail == "low") {
echo "
<a href=db_action.php?table=$table&query=$urlquery&detail=high>Multi-line</a>
| <a href=db_action.php?table=$table&query=$urlquery&detail=high>More detail</a>
";
}
echo "<br><a href=index.php>Return to main admin page</a>\n";
echo " | <a href=index.php>Return to main admin page</a>\n";
echo "<p>\n";
if ($table == "host") {
if ($show_aggregate) {
$result = mysql_query("select sum(d_total) as tot_sum, sum(d_free) as free_sum, " . "sum(m_nbytes) as tot_mem from host" . $query);
$disk_info = mysql_fetch_object($result);
$dt = $disk_info->tot_sum/(1024*1024*1024);
$df = $disk_info->free_sum/(1024*1024*1024);
$mt = $disk_info->tot_mem/(1024*1024);
echo "<p>\n
Sum of total disk space on these hosts:
$dt GB
<p>
Sum of available disk space on these hosts:
$df GB
<p>
Sum of memory on these hosts:
$mt MB
<p>
";
}
}
if ($detail == "low") {
start_table();
switch($table) {
case "result": result_short_header(); break;
case "host": host_short_header(); break;
}
}
$result = mysql_query($main_query);
@ -138,20 +170,24 @@ function append_sql_query($original,$addition,$first) {
if ($detail == "low") {
switch ($table) {
case "result": show_result_short($res); break;
case "host": show_host_short($res); break;
}
} else {
switch ($table) {
case "platform": show_platform($res); break;
case "app": show_app($res); break;
case "app_version": show_app_version($res,$show_xml_docs); break;
case "app_version": show_app_version($res, $hide_xml_docs); break;
case "host": show_host($res); break;
case "workunit": show_workunit($res,$show_xml_docs); break;
case "result": show_result($res,$show_xml_docs,$show_stderr,$show_times); break;
case "workunit": show_workunit($res, $hide_xml_docs); break;
case "result": show_result($res, $hide_xml_docs, $hide_stderr, $hide_times); break;
case "team": show_team($res); break;
case "user": show_user($res); break;
}
}
}
if ($detail == "low") {
end_table();
}
page_tail();
?>

View File

@ -6,6 +6,24 @@
parse_str(getenv("QUERY_STRING"));
function print_detail_field() {
echo "<tr><td align=right>Detail level</td><td>";
echo "<select name=detail>
<option value=low>low
<option value=high>high
</select>
</td></tr>
";
}
function print_query_field() {
echo "
<tr>
<td align=right>Additional clauses</td>
<td><input name=clauses></td>
</tr>
";
}
$first = 1;
$title = table_title($table);
@ -18,26 +36,12 @@
if ($table=="platform") {
} else if ($table=="app") {
} else if ($table=="app_version") {
print_checkbox("Show XML Docs", "show_xml_docs", $show_xml_docs);
print_checkbox("Hide XML Docs", "hide_xml_docs", $hide_xml_docs);
} else if ($table=="host") {
print_checkbox("Show Aggregate Information", "show_aggregate", $show_aggregate);
if ($show_aggregate) {
$result = mysql_query("select sum(d_total) as tot_sum, sum(d_free) as free_sum, "
. "sum(m_nbytes) as tot_mem " . $query);
$disk_info = mysql_fetch_object($result);
printf( "<p>\n"
. "Sum of total disk space on these hosts: "
. $disk_info->tot_sum/(1024*1024*1024) . " GB"
. "<p>"
. "Sum of available disk space on these hosts: "
. $disk_info->free_sum/(1024*1024*1024) . " GB"
. "<p>"
. "Sum of memory on these hosts: " . $disk_info->tot_mem/(1024*1024) . " MB"
. "<p>"
);
}
print_detail_field();
} else if ($table=="workunit") {
print_checkbox("Show XML fields", "show_xml_docs", $show_xml_docs);
print_checkbox("Hide XML fields", "hide_xml_docs", $hide_xml_docs);
} else if ($table=="result") {
echo "<tr><td align=right>Server state</td><td> ";
result_server_state_select();
@ -50,19 +54,14 @@
result_client_state_select();
echo "</td></tr>\n";
row2("Show XML fields", "<input type=checkbox name=show_xml_docs>");
row2("Show result stderr", "<input type=checkbox name=show_stderr>");
row2("Show times", "<input type=checkbox name=show_times>");
row2("Hide XML fields", "<input type=checkbox name=hide_xml_docs>");
row2("Hide result stderr", "<input type=checkbox name=hide_stderr>");
row2("Hide times", "<input type=checkbox name=hide_times>");
echo "<tr><td align=right>Sort by</td><td>";
result_sort_select();
echo "</td></tr>\n";
echo "<tr><td align=right>Detail level</td><td>";
echo "<select name=detail>
<option value=low>low
<option value=high>high
</select>
</td></tr>
";
print_detail_field();
print_query_field();
} else if ($table=="team") {
} else if ($table=="user") {
@ -71,7 +70,7 @@
exit();
}
row2("Number of entries to show", "<input name=nresults>");
row2("Number of entries to show", "<input name=nresults value='10'>");
row2("", "<input type=submit value=\"OK\">\n");
end_table();

View File

@ -4,25 +4,27 @@ require_once("util.inc");
$cgi_url = parse_config("<cgi_url>");
echo <<<EOT
<title>BOINC Project Management</title>
<h2>BOINC Project Management</h2>
<p>
Browse database:
<ul>
<li><a href=db_action.php?table=platform>Platforms</a>
<li><a href=db_form.php?table=app>Applications</a>
<li><a href=db_form.php?table=app_version>Application versions</a>
<li><a href=db_form.php?table=user>Users</a>
<li><a href=db_form.php?table=team>Teams</a>
<li><a href=db_form.php?table=host>Hosts</a>
<li><a href=db_form.php?table=workunit>Workunits</a>
<li><a href=db_form.php?table=result&detail=low>Results</a>
</ul>
<a href=result_summary.php?nsecs=86400>Result summary, last 24 hours</a>
<br>
<a href=$cgi_url/stripchart.cgi>Stripcharts</a>
EOT;
$w = 7*86400;
echo "
<title>BOINC Project Management</title>
<h2>BOINC Project Management</h2>
<p>
Browse database:
<ul>
<li><a href=db_action.php?table=platform>Platforms</a>
<li><a href=db_form.php?table=app>Applications</a>
<li><a href=db_form.php?table=app_version>Application versions</a>
<li><a href=db_form.php?table=user>Users</a>
<li><a href=db_form.php?table=team>Teams</a>
<li><a href=db_form.php?table=host&detail=low>Hosts</a>
<li><a href=db_form.php?table=workunit>Workunits</a>
<li><a href=db_form.php?table=result&detail=low>Results</a>
</ul>
Result summary:
<a href=result_summary.php?nsecs=86400>last 24 hours</a>
<a href=result_summary.php?nsecs=$w>last week</a>
<br>
<a href=$cgi_url/stripchart.cgi>Stripcharts</a>
";
?>