admin interface to DB

svn path=/trunk/boinc/; revision=1404
This commit is contained in:
David Anderson 2003-06-11 23:36:47 +00:00
parent 92989bf106
commit 6917fd9055
6 changed files with 277 additions and 302 deletions

View File

@ -1,233 +0,0 @@
<?php
require_once("util.inc");
require_once("db.inc");
db_init();
function print_header($show) {
switch($show) {
case "platform": $title = "Platforms"; break;
case "app": $title = "Applications"; break;
case "app_version": $title = "Application Versions"; break;
case "host": $title = "Hosts"; break;
case "workunit": $title = "Workunits"; break;
case "result": $title = "Results"; break;
case "team": $title = "Teams"; break;
case "user": $title = "Users"; break;
default: print_page_header("Database"); return;
}
print_page_header($title);
print_form_header($show);
}
parse_str(getenv("QUERY_STRING"));
$first = 1;
$query = "from $show";
$english_query = "Select all from $show";
if (strlen($id)) {
$query = append_sql_query( $query, "id = $id", $first );
$english_query = append_sql_query( $english_query, "id is $id", $first );
$first = 0;
}
if (strlen($plat_id)) {
$query = append_sql_query( $query, "platformid = $plat_id", $first );
$english_query = append_sql_query( $english_query, "platform is ".platform_name_by_id($plat_id), $first );
$first = 0;
}
if (strlen($app_id)) {
$query = append_sql_query( $query, "appid = $app_id", $first );
$english_query = append_sql_query( $english_query, "application is ".app_name_by_id($app_id), $first );
$first = 0;
}
if (strlen($wu_id)) {
$query = append_sql_query( $query, "workunitid = $wu_id", $first );
$english_query = append_sql_query( $english_query, "workunit is ".wu_name_by_id($wu_id), $first );
$first = 0;
}
if (strlen($host_id)) {
$query = append_sql_query( $query, "hostid = $host_id", $first );
$english_query = append_sql_query( $english_query, "host is ".host_name_by_id($host_id), $first );
$first = 0;
}
if (strlen($team_id)) {
$query = append_sql_query( $query, "teamid = $team_id", $first );
$english_query = append_sql_query( $english_query, "team is " . team_name_by_id($team_id), $first );
$first = 0;
}
if (strlen($result_state) && $result_state != 0) {
$query = append_sql_query( $query, "server_state = $result_state", $first );
$english_query = append_sql_query( $english_query, "server state is ".result_server_state_string($result_state), $first );
$rstate = $result_state;
$first = 0;
} else {
$rstate = 0;
}
if (strlen($batch)) {
$query = append_sql_query( $query, "batch = $batch", $first );
$english_query = append_sql_query( $english_query, "batch number is $batch", $first );
$first = 0;
}
if (strlen($nres_done)) {
$query = append_sql_query( $query, "nresults_done = $nres_done", $first );
$english_query = append_sql_query( $english_query, "number of results done is $nres_done", $first );
$first = 0;
}
if (strlen($nres_fail)) {
$query = append_sql_query( $query, "nresults_fail = $nres_fail", $first );
$english_query = append_sql_query( $english_query, "number of results failed is $nres_fail",$first );
$first = 0;
}
if (strlen($nres_unsent)) {
$query = append_sql_query( $query, "nresults_unsent = $nres_unsent", $first );
$english_query = append_sql_query( $english_query, "number of results unsent is $nres_unsent", $first );
$first = 0;
}
if (strlen($client_state)) {
$query = append_sql_query( $query, "client_state = $client_state", $first );
$english_query = append_sql_query( $english_query, "client_state is $client_state", $first );
$first = 0;
}
if (strlen($sort_by)) {
switch ($sort_by) {
case 1:
$query = $query . " order by create_time desc";
$english_query = append_sql_query( $english_query, "most recent created are listed first", $first );
$first = 0;
break;
case 2:
$query = $query . " order by sent_time desc";
$english_query = append_sql_query( $english_query, "most recent sent are listed first", $first );
$first = 0;
break;
case 3:
$query = $query . " order by received_time desc";
$english_query = append_sql_query( $english_query, "most recent received are listed first", $first );
$first = 0;
break;
}
}
if (strlen($nresults)) {
$entries_to_show = $nresults;
} else {
$entries_to_show = 10;
}
if (strlen($show_more)) {
$start_at = $last_pos;
} else {
$start_at = 0;
}
$query = $query . " limit " . ($entries_to_show+$start_at);
print_header($show);
if ($show=="platform") {
} else if ($show=="app") {
} else if ($show=="app_version") {
print_checkbox("Show XML Docs", "show_xml_docs", $show_xml_docs);
} else if ($show=="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>"
);
}
} else if ($show=="workunit") {
print_text_field( "Workunits in batch number:", "batch", $batch );
print_text_field( "Number of results done:", "nres_done", $nres_done );
print_text_field( "Number of results failed:", "nres_fail", $nres_fail );
print_text_field( "Number of results unsent:", "nres_unsent", $nres_unsent );
print_checkbox("Show XML fields", "show_xml_docs", $show_xml_docs);
} else if ($show=="result") {
printf(
"Result State: <select name=result_state>\n"
. "<option value=\"0\"" . ($rstate == 0 ? "selected" : "") . "> All\n"
);
for( $i=1;$i<=6;$i++ ) {
printf( "<option value=\"$i\"" . ($rstate == $i ? "selected" : "") . ">" . result_server_state_string($i) . "\n" );
}
printf( "</select>\n<p>\n" );
print_text_field( "Result in batch number:", "batch", $batch );
print_text_field( "Result has client_state: ", "client_state", $client_state);
print_checkbox("Show XML fields", "show_xml_docs", $show_xml_docs);
print_checkbox("Show result stderr", "show_stderr", $show_stderr);
print_checkbox("Show times", "show_times", $show_times);
printf( "Sort by:<br>\n" );
print_radio_button("None", "sort_by", "0", $sort_by == "0");
print_radio_button("Creation time", "sort_by", "1", $sort_by == "1");
print_radio_button("Sent time", "sort_by", "2", $sort_by == "2");
print_radio_button("Received time", "sort_by", "3", $sort_by == 3);
printf("<br>\n");
} else if ($show=="team") {
} else if ($show=="user") {
} else {
echo "<br><a href=db.php?show=platform>Platforms</a>\n";
echo "<br><a href=db.php?show=app>Apps</a>\n";
echo "<br><a href=db.php?show=app_version>App versions</a>\n";
echo "<br><a href=db.php?show=host>Hosts</a>\n";
echo "<br><a href=db.php?show=workunit>Workunits</a>\n";
echo "<br><a href=db.php?show=result>Results</a>\n";
echo "<br><a href=db.php?show=team>Teams</a>\n";
echo "<br><a href=db.php?show=user>Users</a>\n";
print_page_end();
return;
}
print_text_field( "Number of entries to show:", "nresults", $entries_to_show );
printf( "<input type=hidden name=last_pos value=\"" . ($entries_to_show+$start_at) . "\">\n" );
print_form_end();
echo "<p>Query is: <b>$english_query</b><p>";
print_query_count("select count(*) as cnt " . $query, $entries_to_show, $start_at);
$result = mysql_query("select * " . $query);
while (($res = mysql_fetch_object($result)) && ($entries_to_show > 0)) {
if ($start_at <= 0) {
switch ($show) {
case "platform": show_platform($res); break;
case "app": show_app($res); break;
case "app_version": show_app_version($res,$show_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 "team": show_team($res); break;
case "user": show_user($res); break;
}
$entries_to_show--;
} else {
$start_at--;
}
}
print_page_end();
?>

157
html/ops/db_action.php Normal file
View File

@ -0,0 +1,157 @@
<?php
require_once("util.inc");
require_once("db.inc");
function append_sql_query($original,$addition,$first) {
if ($first == 1) {
return $original . " where " . $addition;
} else {
return $original . " and " . $addition;
}
}
db_init();
parse_str(getenv("QUERY_STRING"));
$first = 1;
if (strlen($id)) {
$query = append_sql_query( $query, "id = $id", $first );
$first = 0;
}
if (strlen($plat_id)) {
$query = append_sql_query( $query, "platformid = $plat_id", $first );
$first = 0;
}
if (strlen($app_id)) {
$query = append_sql_query( $query, "appid = $app_id", $first );
$first = 0;
}
if (strlen($wu_id)) {
$query = append_sql_query( $query, "workunitid = $wu_id", $first );
$first = 0;
}
if (strlen($hostid)) {
$query = append_sql_query( $query, "hostid = $hostid", $first );
$first = 0;
}
if (strlen($team_id)) {
$query = append_sql_query( $query, "teamid = $team_id", $first );
$first = 0;
}
if (strlen($received_time)) {
$query = append_sql_query( $query, "received_time > $received_time", $first );
$first = 0;
}
if (strlen($result_server_state) && $result_server_state>0) {
$query = append_sql_query( $query, "server_state = $result_server_state", $first );
$first = 0;
}
if (strlen($result_outcome) && $result_outcome>0) {
$query = append_sql_query( $query, "outcome = $result_outcome", $first );
$first = 0;
}
if (strlen($result_client_state) && $result_client_state>0) {
$query = append_sql_query( $query, "client_state = $result_client_state", $first );
$first = 0;
}
if (strlen($sort_by)) {
$query = $query . " order by $sort_by desc";
$first = 0;
}
if (strlen($nresults)) {
$entries_to_show = $nresults;
} else {
$entries_to_show = 10;
}
if (strlen($last_pos)) {
$start_at = $last_pos;
} else {
$start_at = 0;
}
page_head($table);
$count_query = "select count(*) as cnt from ".$table." ".$query;
$result = mysql_query($count_query);
$res = mysql_fetch_object($result);
$count = $res->cnt;
if ($count < $start_at + $entries_to_show) {
$entries_to_show = $count - $start_at;
}
$last = $start_at + $entries_to_show;
if ($start_at) {
$main_query = "select * from ".$table." ".$query. " limit ".$start_at.",".$entries_to_show;
} else {
$main_query = "select * from ".$table." ".$query. " limit ".$entries_to_show;
}
echo "<p>Query is: <b>$main_query</b><p>\n";
echo "
<p>$count database entries match the query.
Displaying $start_at to $last.<p>
";
$urlquery = urlencode($query);
if ($last < $count) {
echo "
<a href=db_action.php?table=$table&query=$urlquery&last_pos=$last>Next $n</a>
";
}
if ($detail == "high") {
echo "
<a href=db_action.php?table=$table&query=$urlquery&detail=low>Single-line</a>
";
}
if ($detail == "low") {
echo "
<a href=db_action.php?table=$table&query=$urlquery&detail=high>Multi-line</a>
";
}
echo "<br><a href=index.php>Return to main admin page</a>\n";
if ($detail == "low") {
start_table();
switch($table) {
case "result": result_short_header(); break;
}
}
$result = mysql_query($main_query);
while ($res = mysql_fetch_object($result)) {
if ($detail == "low") {
switch ($table) {
case "result": show_result_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 "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 "team": show_team($res); break;
case "user": show_user($res); break;
}
}
}
page_tail();
?>

81
html/ops/db_form.php Normal file
View File

@ -0,0 +1,81 @@
<?php
require_once("util.inc");
require_once("db.inc");
db_init();
parse_str(getenv("QUERY_STRING"));
$first = 1;
$title = table_title($table);
page_head($title);
echo "<form method=get action=db_action.php>\n";
echo "<p>\n";
echo "<input type=hidden name=table value=$table>\n";
start_table();
if ($table=="platform") {
} else if ($table=="app") {
} else if ($table=="app_version") {
print_checkbox("Show XML Docs", "show_xml_docs", $show_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>"
);
}
} else if ($table=="workunit") {
print_checkbox("Show XML fields", "show_xml_docs", $show_xml_docs);
} else if ($table=="result") {
echo "<tr><td align=right>Server state</td><td> ";
result_server_state_select();
echo "</td></tr>\n";
//print_text_field( "Batch number:", "batch", $batch );
echo "<tr><td align=right>Outcome</td><td>";
result_outcome_select();
echo "</td></tr>\n";
echo "<tr><td align=right>Client state</td><td>";
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>");
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>
";
} else if ($table=="team") {
} else if ($table=="user") {
} else {
echo "Unknown table name\n";
exit();
}
row2("Number of entries to show", "<input name=nresults>");
row2("", "<input type=submit value=\"OK\">\n");
end_table();
echo "</form>\n";
page_tail();
?>

View File

@ -16,7 +16,6 @@ define("TD3", "<td colspan=3 bgcolor=#708090>");
define("TABLE", "<table cellpadding=10 cellspacing=4 border=0 width=100%>");
define("TABLE2", "<table width=580>");
define("BG_COLOR", " bgcolor=cccccc ");
define("TITLE_COLOR", " bgcolor=000000 ");
define("TITLE_FONT", " <font color=ffffff> ");
define("BODY_COLOR", " bgcolor=ffffff ");
@ -44,34 +43,12 @@ function show_login($user) {
}
function page_head($title) {
echo "<head><title>$title</title><body " . BG_COLOR . ">\n";
echo "<head><title>$title</title><body " . BODY_COLOR . ">\n";
echo TABLE . "<tr " . TITLE_COLOR . "><td>" . TITLE_FONT . "<font size=6><b><a href=index.php>".PROJECT.":</a> $title</b></font></td></tr></table>\n";
}
function page_tail() {
echo "<hr><table width=100%><tr><td align=center>|<a href=create_account.php> Create New Account </a>|<a href=login.php> Login </a>\n";
echo "|<a href=home.php> User Page </a>|<a href=team.php> Teams </a>|<a href=index.php> Main Project Page </a>|</td></tr></table>\n";
}
function print_form_header($table) {
echo "<form method=get action=db.php>\n";
echo "<p>\n";
echo "<input type=hidden name=show value=$table>\n";
}
function print_form_end() {
echo "<p>\n";
echo "<input type=submit name=\"new_query\" value=\"Query\">\n";
echo "<input type=submit name=\"show_more\" value=\"Show More\">\n";
echo "</form>\n";
}
function append_sql_query($original,$addition,$first) {
if ($first == 1) {
return $original . " where " . $addition;
} else {
return $original . " and " . $addition;
}
echo "<hr><a href=index.php> Main admin page </a>\n";
}
function date_str($when) {
@ -115,7 +92,7 @@ function row($x, $y) {
}
function row2($x, $y) {
echo "<tr><td>$x</td><td>$y</td></tr>\n";
echo "<tr><td align=right>$x</td><td>$y</td></tr>\n";
}
function row3($x, $y, $z) {
@ -135,21 +112,6 @@ function print_country_select() {
PassThru("country_select");
}
function print_page_header($title) {
echo "<html>\n";
echo "<head>\n";
echo "<title>$title</title>\n";
echo "</head>\n";
echo "<body TEXT=000000 BGCOLOR=FFFFFF>\n";
echo "<h2>$title</h2>\n";
echo "<a href=db.php>Return to Main Page</a>\n";
echo "<br clear=all>\n";
}
function print_page_end() {
echo "</body></html>";
}
// look for an element in some XML text
//
function parse_element($xml, $tag) {
@ -165,11 +127,11 @@ function parse_element($xml, $tag) {
return $element;
}
// look for a particular element in the .htconfig.xml file
// look for a particular element in the config.xml file
//
function parse_config($tag) {
$element = null;
$fp = fopen(".htconfig.xml", "r");
$fp = fopen("config.xml", "r");
while (1) {
$buf = fgets($fp, 1024);
if ($buf == null) break;

View File

@ -676,9 +676,10 @@ bool wrong_major_version(SCHEDULER_REQUEST& sreq, SCHEDULER_REPLY& reply) {
sreq.core_client_major_version
);
strcpy(reply.message_priority, "low");
write_log(MSG_NORMAL, "Wrong major version: wanted %d, got %d\n",
MAJOR_VERSION, sreq.core_client_major_version
);
sprintf(buf, "Wrong major version from user [%s]: wanted %d, got %d\n",
sreq.authenticator, MAJOR_VERSION, sreq.core_client_major_version
);
write_log(buf, MSG_NORMAL);
return true;
}
return false;

View File

@ -10,47 +10,54 @@
$project->short_name = "apt";
$project->long_name = "Astropulse";
$platform = new Platform("windows_intelx86", "Windows");
// Solaris version
$platform_sol = new Platform("sparc-sun-solaris2.7", "Solaris");
$app = new App("Astropulse");
$app_version = new App_Version($app);
$app_version->platform = $platform;
$app_version->exec_dir = "../apps";
$app_version->version = 5;
$app_version->exec_name = "ap_win_0.05.exe";
$app_version_sol = new App_Version($app);
$app_version_sol->platform = $platform_sol;
$app_version_sol->exec_dir = "../apps";
$app_version_sol->version = 9;
$app_version_sol->exec_name = "ap_sparc_0.09";
// Linux version
$platform_lin = new Platform("i686-pc-linux-gnu", "Linux");
$app_version_lin = new App_Version($app);
$app_version_lin->platform = $platform_lin;
$app_version_lin->exec_dir = "../apps";
$app_version_lin->version = 9;
$app_version_lin->exec_name = "ap_linux_0.09";
/*
$core_app = new App("core client");
$core_app_version = new App_Version($core_app);
$core_app_version->platform = $platform;
$core_app_version->exec_dir = "../apps";
$core_app_version->version = 13;
$core_app_version->exec_name = "BOINC_0.13a.exe";
*/
$project->add_app($app);
$project->add_app_version($app_version);
$project->add_app($core_app);
$project->add_app_version($core_app_version);
$project->start_assimilator = false;
$project->start_feeder = true;
$project->start_file_deleter = false;
$project->start_make_work = true;
$project->make_work_wu_template = "pulse_wu";
$project->make_work_result_template = "pulse_result";
$project->start_timeout_check = false;
$project->start_validate = false;
$project->shmem_key = 0x31415927;
$project->add_app_version($app_version_sol);
$project->add_app_version($app_version_lin);
//$project->add_app($core_app);
//$project->add_app_version($core_app_version);
$project->shmem_key = 0x3141a666;
$project->project_php_file = "project_ap.inc";
$project->project_prefs_php_file = "project_specific_prefs_ap.inc";
$project->install();
$project->http_password("admin","mypass");
$project->install_feeder();
$project->install_assimilator($app);
$project->install_file_delete();
$project->install_validate($app,3);
$project->start_servers();
$work = new Work($app);
/*$work = new Work($app);
$work->wu_template = "pulse_wu";
$work->result_template = "pulse_result";
$work->redundancy = 5;
array_push($work->input_files, "03au00ab_20575_00000.wu");
$work->install($project);
$project->start_servers();
$work->install($project);*/
?>