From 6917fd90557551421102b61e813c9317a51c5065 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 11 Jun 2003 23:36:47 +0000 Subject: [PATCH] admin interface to DB svn path=/trunk/boinc/; revision=1404 --- html/ops/db.php | 233 --------------------------------------- html/ops/db_action.php | 157 ++++++++++++++++++++++++++ html/ops/db_form.php | 81 ++++++++++++++ html/ops/util.inc | 48 +------- sched/handle_request.C | 7 +- test/make_project_ap.php | 53 +++++---- 6 files changed, 277 insertions(+), 302 deletions(-) delete mode 100644 html/ops/db.php create mode 100644 html/ops/db_action.php create mode 100644 html/ops/db_form.php diff --git a/html/ops/db.php b/html/ops/db.php deleted file mode 100644 index 2725ed83ca..0000000000 --- a/html/ops/db.php +++ /dev/null @@ -1,233 +0,0 @@ -\n" - . "Sum of total disk space on these hosts: " - . $disk_info->tot_sum/(1024*1024*1024) . " GB" - . "

" - . "Sum of available disk space on these hosts: " - . $disk_info->free_sum/(1024*1024*1024) . " GB" - . "

" - . "Sum of memory on these hosts: " . $disk_info->tot_mem/(1024*1024) . " MB" - . "

" - ); - } - } 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: \n

\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:
\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("
\n"); - } else if ($show=="team") { - } else if ($show=="user") { - } else { - echo "
Platforms\n"; - echo "
Apps\n"; - echo "
App versions\n"; - echo "
Hosts\n"; - echo "
Workunits\n"; - echo "
Results\n"; - echo "
Teams\n"; - echo "
Users\n"; - print_page_end(); - return; - } - - print_text_field( "Number of entries to show:", "nresults", $entries_to_show ); - printf( "\n" ); - print_form_end(); - - echo "

Query is: $english_query

"; - - 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(); -?> diff --git a/html/ops/db_action.php b/html/ops/db_action.php new file mode 100644 index 0000000000..9382ef9d39 --- /dev/null +++ b/html/ops/db_action.php @@ -0,0 +1,157 @@ + $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 "

Query is: $main_query

\n"; + echo " +

$count database entries match the query. + Displaying $start_at to $last.

+ "; + + $urlquery = urlencode($query); + if ($last < $count) { + echo " + Next $n + "; + } + if ($detail == "high") { + echo " + Single-line + "; + } + if ($detail == "low") { + echo " + Multi-line + "; + } + + echo "
Return to main admin page\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(); +?> diff --git a/html/ops/db_form.php b/html/ops/db_form.php new file mode 100644 index 0000000000..d5a9815a76 --- /dev/null +++ b/html/ops/db_form.php @@ -0,0 +1,81 @@ +\n"; + echo "

\n"; + echo "\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( "

\n" + . "Sum of total disk space on these hosts: " + . $disk_info->tot_sum/(1024*1024*1024) . " GB" + . "

" + . "Sum of available disk space on these hosts: " + . $disk_info->free_sum/(1024*1024*1024) . " GB" + . "

" + . "Sum of memory on these hosts: " . $disk_info->tot_mem/(1024*1024) . " MB" + . "

" + ); + } + } else if ($table=="workunit") { + print_checkbox("Show XML fields", "show_xml_docs", $show_xml_docs); + } else if ($table=="result") { + echo "Server state "; + result_server_state_select(); + echo "\n"; + //print_text_field( "Batch number:", "batch", $batch ); + echo "Outcome"; + result_outcome_select(); + echo "\n"; + echo "Client state"; + result_client_state_select(); + echo "\n"; + + row2("Show XML fields", ""); + row2("Show result stderr", ""); + row2("Show times", ""); + echo "Sort by"; + result_sort_select(); + echo "\n"; + echo "Detail level"; + echo " + + "; + + } else if ($table=="team") { + } else if ($table=="user") { + } else { + echo "Unknown table name\n"; + exit(); + } + + row2("Number of entries to show", ""); + + row2("", "\n"); + end_table(); + echo "\n"; + + page_tail(); +?> diff --git a/html/ops/util.inc b/html/ops/util.inc index 80a21e33bb..a7736e3fa9 100644 --- a/html/ops/util.inc +++ b/html/ops/util.inc @@ -16,7 +16,6 @@ define("TD3", ""); define("TABLE", ""); define("TABLE2", "
"); -define("BG_COLOR", " bgcolor=cccccc "); define("TITLE_COLOR", " bgcolor=000000 "); define("TITLE_FONT", " "); define("BODY_COLOR", " bgcolor=ffffff "); @@ -44,34 +43,12 @@ function show_login($user) { } function page_head($title) { - echo "$title\n"; + echo "$title\n"; echo TABLE . "
" . TITLE_FONT . "".PROJECT.": $title
\n"; } function page_tail() { - echo "


| Create New Account | Login \n"; - echo "| User Page | Teams | Main Project Page |
\n"; -} - -function print_form_header($table) { - echo "
\n"; - echo "

\n"; - echo "\n"; -} - -function print_form_end() { - echo "

\n"; - echo "\n"; - echo "\n"; - echo "

\n"; -} - -function append_sql_query($original,$addition,$first) { - if ($first == 1) { - return $original . " where " . $addition; - } else { - return $original . " and " . $addition; - } + echo "
Main admin page \n"; } function date_str($when) { @@ -115,7 +92,7 @@ function row($x, $y) { } function row2($x, $y) { - echo "$x$y\n"; + echo "$x$y\n"; } function row3($x, $y, $z) { @@ -135,21 +112,6 @@ function print_country_select() { PassThru("country_select"); } -function print_page_header($title) { - echo "\n"; - echo "\n"; - echo "$title\n"; - echo "\n"; - echo "\n"; - echo "

$title

\n"; - echo "Return to Main Page\n"; - echo "
\n"; -} - -function print_page_end() { - echo ""; -} - // 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; diff --git a/sched/handle_request.C b/sched/handle_request.C index f5028849e2..641a73dfb2 100644 --- a/sched/handle_request.C +++ b/sched/handle_request.C @@ -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; diff --git a/test/make_project_ap.php b/test/make_project_ap.php index 5542fb2a3c..21753bff5a 100644 --- a/test/make_project_ap.php +++ b/test/make_project_ap.php @@ -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);*/ ?>