\n"; define("NVALIDATE_STATES", 5); // Function prints a description of $table // function print_describe_table_onecol($table, $which, $columns) { $result=mysql_query("SELECT * from $table LIMIT 1"); $fields=mysql_num_fields($result); $avgnum=(int)($fields/$columns); if ($avgnum*$columns<$fields) { $avgnum++; } $actualcolumns=0; while ($avgnum*$actualcolumns<$fields) { $actualcolumns++; } if ($which>$actualcolumns) { return 0; } $bot=($which-1)*$avgnum; $top=$which*$avgnum; $width=100.0/$actualcolumns; // echo "\n"; echo ""; return 0; } function print_describe_table($table, $how_many_columns) { // Number of columns for showing table description echo "

Description of $table table fields:

\n"; echo "
\n"; echo "\n"; for ($count=$bot; $count<$top; $count++) { if ($count<$fields) { $name= mysql_field_name($result, $count); $type= mysql_field_type($result, $count); $length=mysql_field_len($result, $count); } else { $name="
"; $type="
"; $length="
"; } echo "\t\n"; } echo "
NAMETypeBytes
$name$type$length
\n\t"; for ($i=1; $i<=$how_many_columns; $i++) { print_describe_table_onecol($table, $i, $how_many_columns); } echo "\t\n
\n"; return 0; } function join_query_string($s1, $s2) { if ($s1) { if ($s2) { return "$s1&s2"; } else { return $s1; } } else { return $s2; } } // SqlQueryString maps a bunch of form items to a SQL query // // The items are // table (name of table) // id // platformid // appid // workunitid // hostid // userid // teamid // nsecs (received_time > now - nsecs) // received_time (> x) // server_state (== x if z nonzero) // outcome (== x if z nonzero) // client_state (== x if z nonzero) // exit_status (== x if z nonzero) // clauses (literals added after the above) // sort_by (order by x desc added after all else) // // Once you've parsed the items (using parse_form_items()): // // get_select_query(n, m) returns the SQL query to get items from m to m+n // get_url() returns the URL-encoded version of everything // count() returns the number of records satisfying the query class SqlQueryString { var $table; var $query; var $urlquery; function SqlQueryString() { $this->table = $_GET['table']; //$this->query = $_GET['query']; $this->query = ""; $this->urlquery = ""; } function add($clause) { //$clause=boinc_real_escape_string($clause); if (!$this->query) { $this->query .= "where $clause"; } else { $this->query .= " and $clause"; } } function addclause($clause) { if ($clause) { $this->add($clause); $this->urlquery .= "&clauses=".urlencode($clause); } } function addeq($name) { $value = $_GET[$name]; if (strlen($value)) { $this->add("$name = '$value'"); $this->urlquery .= "&$name=".urlencode($value); } } function addeq_not_CHOOSE_ALL($name) { $value = $_GET[$name]; // On the selection menu, the ALL selection criteria sets (for example) // outcome=='CHOOSE_ALL' rather than a numeric value. This means that // we enter no condition for this case. if (strlen($value) && strcmp("CHOOSE_ALL", $value)) { $this->add("$name = '$value'"); $this->urlquery .= "&$name=".urlencode($value); } } function addgt($name) { $value = $_GET[$name]; if (strlen($value) && $value > 0) { $this->add("$name > '$value'"); $this->urlquery .= "&$name=".urlencode($value); } } function addsort($name) { $value = $_GET[$name]; if (strlen($value)) { $this->query .= " order by $value desc"; $this->urlquery .= "&$name=".urlencode($value); } } function count() { $count_query = "select count(*) as cnt from $this->table $this->query"; $result = mysql_query($count_query); if (!$result) return 0; $res = mysql_fetch_object($result); mysql_free_result($result); return $res->cnt; } function get_select_query($entries_to_show, $start_at) { if ($entries_to_show) { if ($start_at) { return "select * from $this->table $this->query limit $start_at,$entries_to_show"; } else { return "select * from $this->table $this->query limit $entries_to_show"; } } else { return "select * from $this->table $this->query"; } } function get_url($base) { $s = "db_action.php?table=$this->table$this->urlquery"; return $s; } function process_form_items() { $this->addeq('id'); $this->addeq('platformid'); $this->addeq('appid'); $this->addeq('workunitid'); $this->addeq('hostid'); $this->addeq('userid'); $this->addeq('teamid'); $this->addeq('exit_status'); if ($_GET['nsecs']) { $_GET['mod_time'] = date("YmdHis",time() - $_GET['nsecs']); } $this->addgt('mod_time'); $this->addeq_not_CHOOSE_ALL('server_state'); $this->addeq_not_CHOOSE_ALL('outcome'); $this->addeq_not_CHOOSE_ALL('client_state'); $this->addeq_not_CHOOSE_ALL('validate_state'); if ($_GET['clauses']) { $this->addclause("( " . urldecode($_GET['clauses']) . " )"); } $this->addsort('sort_by'); } } function link_results($n, $mq, $query, $clauses) { if ($n == '0') { // intentional compare by string return "0"; } else { if(strlen($clauses)) { return "$n"; } else { return "$n"; } } } // Decode ErrorNumber into human readable, taken from lib/error_numbers.h keep this up to date // @return String A human readable error message // @param Integer $x An error number function result_error_mask_str($x){ switch($x){ case 0: return ""; case -100: return "ERR_SELECT"; case -101: return "ERR_MALOC"; case -102: return "ERR_READ"; case -103: return "ERR_WRITE"; case -104: return "ERR_FREAD"; case -105: return "ERR_FWRITE"; case -106: return "ERR_IO"; case -107: return "ERR_CONNECT"; case -108: return "ERR_FOPEN"; case -109: return "ERR_RENAME"; case -110: return "ERR_UNLINK"; case -111: return "ERR_OPENDIR"; case -112: return "ERR_XML_PARSE"; case -113: return "ERR_GETHOSTBYNAME"; case -113: return "ERR_GETHOSTBYNAME"; case -114: return "ERR_GIVEUP_DOWNLOAD"; case -115: return "ERR_GIVEUP_UPLOAD"; case -116: return "ERR_NULL"; case -117: return "ERR_NEG"; case -118: return "ERR_BUFFER_OVERFLOW"; case -119: return "ERR_MD5_FAILED"; case -120: return "ERR_RSA_FAILED"; case -121: return "ERR_OPEN"; case -122: return "ERR_DUP2"; case -123: return "ERR_NO_SIGNATURE"; case -124: return "ERR_THREAD"; case -125: return "ERR_SIGNAL_CATCH"; case -126: return "ERR_QUIT_REQUEST"; case -127: return "ERR_UPLOAD_TRANSIENT"; case -128: return "ERR_UPLOAD_PERMANENT"; case -129: return "ERR_IDLE_PERIOD"; case -130: return "ERR_ALREADY_ATTACHED"; case -131: return "ERR_FILE_TOO_BIG"; case -132: return "ERR_GETRUSAGE"; case -133: return "ERR_BENCHMARK_FAILED"; case -134: return "ERR_BAD_HEX_FORMAT"; case -135: return "ERR_USER_REJECTED"; case -136: return "ERR_DB_NOT_FOUND"; case -137: return "ERR_DB_NOT_UNIQUE"; case -138: return "ERR_DB_CANT_CONNECT"; case -139: return "ERR_GETS"; case -140: return "ERR_SCANF"; case -141: return "ERR_STRCHR"; case -142: return "ERR_STRSTR"; case -143: return "ERR_READDIR"; case -144: return "ERR_SHMGET"; case -145: return "ERR_SHMCTL"; case -146: return "ERR_SHMAT"; case -147: return "ERR_FORK"; case -148: return "ERR_EXEC"; case -149: return "ERR_NOT_EXITED"; case -150: return "ERR_NOT_IMPLEMENTED"; case -151: return "ERR_GETHOSTNAME"; case -152: return "ERR_NETOPEN"; case -153: return "ERR_SOCKET"; case -154: return "ERR_FCNTL"; case -155: return "ERR_AUTHENTICATOR"; case -156: return "ERR_SCHED_SHMEM"; case -157: return "ERR_ASYNCSELECT"; case -158: return "ERR_BAD_RESULT_STATE"; case -159: return "ERR_DB_CANT_INIT"; case -160: return "ERR_NOT_UNIQUE"; case -161: return "ERR_NOT_FOUND"; case -162: return "ERR_NO_EXIT_STATUS"; case -163: return "ERR_FILE_MISSING"; case -164: return "ERR_NESTED_UNHANDLED_EXCEPTION_DETECTED"; case -165: return "ERR_SEMGET"; case -166: return "ERR_SEMCTL"; case -167: return "ERR_SEMOP"; case -168: return "ERR_FTOK"; case -169: return "ERR_SOCKS_UNKNOWN_FAILURE"; case -170: return "ERR_SOCKS_REQUEST_FAILED"; case -171: return "ERR_SOCKS_BAD_USER_PASS"; case -172: return "ERR_SOCKS_UNKNOWN_SERVER_VERSION"; case -173: return "ERR_SOCKS_UNSUPPORTED"; case -174: return "ERR_SOCKS_CANT_REACH_HOST"; case -175: return "ERR_SOCKS_CONN_REFUSED"; case -176: return "ERR_TIMER_INIT"; case -177: return "ERR_RSC_LIMIT_EXCEEDED"; case -178: return "ERR_INVALID_PARAM"; case -179: return "ERR_SIGNAL_OP"; case -180: return "ERR_BIND"; case -181: return "ERR_LISTEN"; case -182: return "ERR_TIMEOUT"; case -183: return "ERR_PROJECT_DOWN"; case -184: return "ERR_HTTP_ERROR"; case -185: return "ERR_RESULT_START"; case -186: return "ERR_RESULT_DOWNLOAD"; case -187: return "ERR_RESULT_UPLOAD"; case -189: return "ERR_INVALID_URL"; case -190: return "ERR_MAJOR_VERSION"; case -191: return "ERR_NO_OPTION"; case -192: return "ERR_MKDIR"; case -193: return "ERR_INVALID_EVENT"; case -194: return "ERR_ALREADY_RUNNING"; default: return "Unknown error number please look at lib/error_numbers.h"; } } // Determines if in stderr_out is an error reported and prints as human readable String // @return String A human readable string if error otherwise FALSE // @param String $stderr_out the stderr_out value to parse function stderr_error_string($stderr_out){ $y = parse_element($stderr_out, ""); if ($y) { $x = (int)$y; } if (0<=$x && $x<=9) { return FALSE; } else { return "$x ".result_error_mask_str($x); } } // function exit_status_string($result) { $x = $result->exit_status; if ($x == 0) { $y = parse_element($result->stderr_out, ""); if ($y) { $x = (int)$y; } } if (0<=$x && $x<=9) { return "$x ".result_error_mask_str($x); } else { return sprintf("%d (0x%x)", $x, $x). " ".result_error_mask_str($x); } } function show_result_summary() { $ntotal =0; // TODO: how to count $result? $nvalid = 0; // for SUCCESS results $ninvalid = 0; $nfile_deleted = 0; $server_state = array(); $outcome = array(); $client_state = array(); for ($ss=1; $ss<6; $ss++) { $server_state[$ss] = 0; } for ($ro=0; $ro<7; $ro++) { $outcome[$ro] = 0; } for ($cs=1; $cs<6; $cs++) { $client_state[$cs] = 0; } for ($fds=0; $fds<3; $fds++) { $delete_state[$fds] = 0; } for ($vs=0; $vsprocess_form_items(); // Important: these need to be kept consistent with db/boinc_db.h and lib/result_state.h $main_query = " SELECT COUNT(id) AS nTotal, SUM(case when server_state = '1' then 1 else 0 end) AS serverstate_inactive, SUM(case when server_state = '2' then 1 else 0 end) AS serverstate_unset, SUM(case when server_state = '3' then 1 else 0 end) AS serverstate_unset_seq, SUM(case when server_state = '4' then 1 else 0 end) AS serverstate_inprogress, SUM(case when server_state = '5' then 1 else 0 end) AS serverstate_over, SUM(case when server_state = '5' and outcome = '0' then 1 else 0 end) AS outcome_init, SUM(case when server_state = '5' and outcome = '1' then 1 else 0 end) AS outcome_success, SUM(case when server_state = '5' and outcome = '2' then 1 else 0 end) AS outcome_couldntsend, SUM(case when server_state = '5' and outcome = '3' then 1 else 0 end) AS outcome_failure, SUM(case when server_state = '5' and outcome = '4' then 1 else 0 end) AS outcome_noreply, SUM(case when server_state = '5' and outcome = '5' then 1 else 0 end) AS outcome_didntneed, SUM(case when server_state = '5' and outcome = '6' then 1 else 0 end) AS outcome_validateerror, SUM(case when server_state = '5' and outcome = '1' and validate_state = '0' then 1 else 0 end) AS validate_init, SUM(case when server_state = '5' and outcome = '1' and validate_state = '1' then 1 else 0 end) AS validate_valid, SUM(case when server_state = '5' and outcome = '1' and validate_state = '2' then 1 else 0 end) AS validate_invalid, SUM(case when server_state = '5' and outcome = '1' and validate_state = '3' then 1 else 0 end) AS validate_nocheck, SUM(case when server_state = '5' and outcome = '1' and validate_state = '4' then 1 else 0 end) AS validate_inconclusive, SUM(case when server_state = '5' and outcome = '1' and file_delete_state = '0' then 1 else 0 end) AS filedeletestate_init, SUM(case when server_state = '5' and outcome = '1' and file_delete_state = '1' then 1 else 0 end) AS filedeletestate_ready, SUM(case when server_state = '5' and outcome = '1' and file_delete_state = '2' then 1 else 0 end) AS filedeletestate_done, SUM(case when server_state = '5' and outcome = '3' and client_state = '0' then 1 else 0 end) AS clientstate_init, SUM(case when server_state = '5' and outcome = '3' and client_state = '1' then 1 else 0 end) AS clientstate_downloading, SUM(case when server_state = '5' and outcome = '3' and client_state = '2' then 1 else 0 end) AS clientstate_downloaded, SUM(case when server_state = '5' and outcome = '3' and client_state = '3' then 1 else 0 end) AS clientstate_computedone, SUM(case when server_state = '5' and outcome = '3' and client_state = '4' then 1 else 0 end) AS clientstate_uploading, SUM(case when server_state = '5' and outcome = '3' and client_state = '5' then 1 else 0 end) AS clientstate_uploaded FROM result WHERE "; if ($query_appid) { $main_query .= "appid=$query_appid and "; } if ($query_wuid) { $main_query .= "workunitid=$query_wuid and "; } if ($query_mod_time) { $main_query .= "mod_time > DATE_SUB( NOW()+0, INTERVAL $query_mod_time SECOND )+0 and "; } $main_query .= "1=1"; $urlquery = $q->urlquery; $result = mysql_query($main_query); // echo "Main query was $main_query
"; if ($result) { $res = mysql_fetch_object($result); $ntotal = $res->nTotal; $server_state[1] = $res->serverstate_inactive; $server_state[2] = $res->serverstate_unset; $server_state[3] = $res->serverstate_unset_seq; $server_state[4] = $res->serverstate_inprogress; $server_state[5] = $res->serverstate_over; $outcome[0] = $res->outcome_init; $outcome[1] = $res->outcome_success; $outcome[2] = $res->outcome_couldntsend; $outcome[3] = $res->outcome_failure; $outcome[4] = $res->outcome_noreply; $outcome[5] = $res->outcome_didntneed; $outcome[6] = $res->outcome_validateerror; $client_state[1] = $res->clientstate_downloading; $client_state[2] = $res->clientstate_downloaded; $client_state[3] = $res->clientstate_computedone; $client_state[4] = $res->clientstate_uploading; $client_state[5] = $res->clientstate_uploaded; $validate_state[0] = $res->validate_init; $validate_state[1] = $res->validate_valid; $validate_state[2] = $res->validate_invalid; $validate_state[3] = $res->validate_nocheck; $validate_state[4] = $res->validate_inconclusive; $file_delete[0] = $res->filedeletestate_init; $file_delete[1] = $res->filedeletestate_ready; $file_delete[2] = $res->filedeletestate_done; $nfile_deleted = $res->filedeletestate_ready + $res->filedeletestate_done; mysql_free_result($result); } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "

" . link_results("$ntotal results", $urlquery, '', '') . "

" . link_results("'Over' results", $urlquery, "server_state=5", '') . "

" . link_results("'Success' results", $urlquery, "outcome=1", '') . "

" . link_results("'Client error' results", $urlquery, "outcome=3", '') . "

\n"; for ($ss=1; $ss<6; $ss++) { row2(server_state_string($ss), link_results("$server_state[$ss]", $urlquery,"server_state=$ss", '')); } echo "
Server state# results
\n"; for ($ro=0; $ro<7; $ro++) { c_row2($outcome[$ro]?outcome_color($ro):'', outcome_string($ro), link_results("$outcome[$ro]", $urlquery, "outcome=$ro", '') ); } echo "
Outcome# results
\n"; for ($vs=0; $vs"; echo "
Validate state# results
\n"; for ($fds=0; $fds<3; $fds++) { row2(file_delete_state_str($fds), link_results("$file_delete[$fds]", $urlquery, "outcome=1", "file_delete_state=$fds")); } row2("Total files deleted", link_results("$nfile_deleted", $urlquery, "outcome=1", "(file_delete_state=1 or file_delete_state=2)")); echo "
File Delete state# results
\n"; for ($cs=1; $cs<6; $cs++) { row2(client_state_string($cs), link_results("$client_state[$cs]", $urlquery, "client_state=$cs", "outcome=3") ); } echo "
Client state# results
"; } function server_state_select() { echo " \n"; } function outcome_select() { echo " \n"; } function validate_state_select() { echo " \n"; } function client_state_select() { echo " \n"; } function result_sort_select() { echo " "; } function table_title($table) { switch($table) { case "platform": return "Platforms"; case "app": return "Applications"; case "app_version": return "Application Versions"; case "host": return "Hosts"; case "workunit": return "Workunits"; case "result": return "Results"; case "team": return "Teams"; case "user": return "Users"; default: return "????"; } } function show_platform($platform) { start_table(); row("ID", $platform->id); row("Created", time_str($platform->create_time)); row("Name", $platform->name); row("User friendly name", $platform->user_friendly_name); row("","id>App versions for this platform"); end_table(); } function show_app($app) { start_table(); row("ID", $app->id); row("Created", time_str($app->create_time)); row("Name", $app->name); row("User-friendly name", $app->user_friendly_name); row("Deprecated", $app->deprecated); row("Homogeneous redundancy", $app->homogeneous_redundancy); row("","id>App Versions for this application"); row("","id&detail=low>Workunits for this application"); end_table(); } function show_app_version($app_version) { start_table(); row("ID", $app_version->id); row("Created", time_str($app_version->create_time)); row("Application", "appid>" . app_name_by_id($app_version->appid) . ""); row("Version num", $app_version->version_num); row("Platform", "platformid>" . platform_name_by_id($app_version->platformid) . "" ); row("XML doc", "
".htmlspecialchars($app_version->xml_doc)."
"); row("Min_core_version", $app_version->min_core_version); row("Max_core_version", $app_version->max_core_version); row("Message", $app_version->message); row("Deprecated", $app_version->deprecated); end_table(); } function app_version_short_header() { echo " ID Application Version Platform "; } function show_app_version_short($app_version) { $x = app_name_by_id($app_version->appid); $y = platform_name_by_id($app_version->platformid); echo " id>$app_version->id appid>$x $app_version->version_num platformid>$y "; } function host_short_header() { echo " host ID IP address name CPU OS "; } function show_host_short($host) { echo " id>$host->id $host->last_ip_addr $host->domain_name $host->p_vendor $host->p_model $host->os_name $host->os_version "; } function show_host($host) { start_table(); row("ID", $host->id); row("Created", time_str($host->create_time)); row("User", "userid>$host->userid"); row("Venue", $host->venue); row("Total credit", $host->total_credit); row("Average credit", $host->expavg_credit); row("Average update time", time_str($host->expavg_time)); row("IP address", "$host->last_ip_addr
(same the last $host->nsame_ip_addr times)"); row("Domain name", $host->domain_name); $x = $host->timezone/3600; row("Time zone", "UTC - $x hours"); row("Number of CPUs", $host->p_ncpus); row("CPU", "$host->p_vendor $host->p_model"); row("FP ops/sec", $host->p_fpops); row("Int ops/sec", $host->p_iops); row("memory bandwidth", $host->p_membw); row("Operating System", "$host->os_name $host->os_version"); $x = $host->m_nbytes/(1024*1024); $y = round($x, 2); row("Memory", "$y MB"); $x = $host->m_cache/1024; $y = round($x, 2); row("Cache", "$y KB"); $x = $host->m_swap/(1024*1024); $y = round($x, 2); row("Swap Space", "$y MB"); $x = $host->d_total/(1024*1024*1024); $y = round($x, 2); row("Total Disk Space", "$y GB"); $x = $host->d_free/(1024*1024*1024); $y = round($x, 2); row("Free Disk Space", "$y GB"); row("Avg network bandwidth (upstream)", "$host->n_bwup bytes/sec"); row("Avg network bandwidth (downstream)", "$host->n_bwdown bytes/sec"); $x = $host->avg_turnaround/86400; row("Average turnaround", "$x days"); row("Number of RPCs", $host->rpc_seqno); row("Last RPC", time_str($host->rpc_time)); 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("# of results today", $host->nresults_today); row("Results", "id&sort_by=sent_time>click here"); end_table(); } function wu_error_mask_str($s) { $x = ""; if ($s & 1) { $x = $x."Couldn't send result;
"; $s -= 1; } if ($s & 2) { $x = $x."Too many errors (may have bug);
"; $s -= 2; } if ($s & 4) { $x = $x."Too many results (may be nondeterministic)
"; $s -= 4; } if ($s & 8) { $x = $x."Too many total results
"; $s -= 8; } if ($s & 16) { $x = $x."WU cancelled
"; $s -= 16; } if ($s) { $x = $x."Unrecognized Error: $s
"; } if (strlen($x)) { $x="".$x.""; } else { $x="
"; } return $x; } function assimilate_state_str($s) { switch($s) { case 0: return "Initial"; case 1: return "Ready to assimilate"; case 2: return "Assimilated"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function file_delete_state_str($s) { switch($s) { case 0: return "Initial"; case 1: return "Ready to delete"; case 2: return "Deleted"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function show_workunit($wu) { $_GET = array('workunitid' => $wu->id); show_result_summary(); start_table(); row("Created", time_str($wu->create_time)); row("Transition Time", time_str($wu->transition_time)); row("Last time modified",mysqltime_str($wu->mod_time)); row("Name", $wu->name); row("XML doc", "
".htmlspecialchars($wu->xml_doc)."
"); row("Application", "appid\">" . app_name_by_id($wu->appid) . " [".$wu->appid."]"); row("Batch", $wu->batch); row("Estimated FP Operations", $wu->rsc_fpops_est); row("Max FP Operations", $wu->rsc_fpops_bound); row("Max Memory Usage", $wu->rsc_memory_bound); row("Max Disk Usage", $wu->rsc_disk_bound); row("Need validate?", ($wu->need_validate?"yes [":"no [").$wu->need_validate."]"); row("Canonical resultid", "canonical_resultid\">".$wu->canonical_resultid.""); row("Canonical credit", $wu->canonical_credit); //row("Timeout check time", time_str($wu->timeout_check_time)); row("Delay bound", "$wu->delay_bound" . " = " . time_diff($wu->delay_bound) ); row("Error mask", wu_error_mask_str($wu->error_mask)); row("File delete state", file_delete_state_str($wu->file_delete_state)." [".$wu->file_delete_state."]"); row("Assimilation state", assimilate_state_str($wu->assimilate_state)." [".$wu->assimilate_state."]"); // row("","id&detail=low>Show associated results"); row("min quorum", $wu->min_quorum); row("target results", $wu->target_nresults); row("max error results", $wu->max_error_results); row("max total results", $wu->max_total_results); row("max success results", $wu->max_success_results); row("result template file",$wu->result_template_file); row("hr_class", $wu->hr_class); row("opaque", $wu->opaque); row("Priority", $wu->priority); end_table(); echo "
"; echo "GREP LOGS FOR THIS WORKUNIT"; echo "
"; echo "

"; } function workunit_short_header() { echo " WU ID canonical result error_mask file delete assimilate "; } function show_workunit_short($wu) { if ($wu->canonical_resultid) { $cr = "canonical_resultid>$wu->canonical_resultid"; } else { $cr = "none"; } $wu_link = "id."&detail=high\">".$wu->id.""; $cr = $cr. " id&detail=low>all"; $e = wu_error_mask_str($wu->error_mask); $f = file_delete_state_str($wu->file_delete_state); $a = assimilate_state_str($wu->assimilate_state); echo " $wu_link $cr $e $f $a "; } function server_state_string($s) { switch($s) { case 1: return "Inactive"; case 2: return "Unsent"; case 3: return "Unsent (in work seq)"; case 4: return "In Progress"; case 5: return "Over"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function outcome_string($s) { switch($s) { case 0: return "Init"; case 1: return "Success"; case 2: return "Couldn't send"; case 3: return "Client error"; case 4: return "No reply"; case 5: return "Didn't need"; case 6: return "Validate error"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function client_state_string($s) { switch($s) { case 0: return "New"; case 1: return "Downloading"; case 2: return "Downloaded"; case 3: return "Computing"; case 4: return "Uploading"; case 5: return "Done"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function validate_state_str($s) { switch($s) { case 0: return "Initial"; case 1: return "Valid"; case 2: return "Invalid"; case 3: return "Skipped"; case 4: return "Inconclusive"; } echo "THIS IS AN INTERNAL BUG IN BOINC: PLEASE CONTACT BOINC DEVELOPERS
"; return "Unknown"; } function host_user_link($hostid) { if (!$hostid) return '----'; $h = "$hostid"; $result = mysql_query("select userid from host where id='$hostid' limit 1"); if (!$result) return $h; $host = mysql_fetch_object($result); mysql_free_result($result); if (!$host->userid) return $h; $result = mysql_query("select * from user where id='$host->userid' limit 1"); if (!$result) return $h; $user = mysql_fetch_object($result); mysql_free_result($result); return "$h
(id>$user->name)"; } function validate_color($validate_state) { switch ($validate_state) { case 1: return '33cc33'; // valid, green case 2: return 'ffa500'; // invalid result, orange } return ''; } function outcome_color($outcome) { switch($outcome) { // case 0: return 'eeeeee'; // unknown (server state not over probably) case 1: return '33cc33'; // "Success", green case 3: return 'ff3333'; // "Client error", red case 6: return 'ffff33'; // "Validate error", yellow } return ''; } function credit_str($c) { if ($c) { return sprintf("%.3f", $c); } else { return '---'; } } function show_result($result) { $wu_name = wu_name_by_id($result->workunitid); start_table(); row("Created", time_str($result->create_time)); row("Sent", time_str($result->sent_time)); row("Received", time_str($result->received_time)); row("Last time modified",mysqltime_str($result->mod_time)); row("Name", $result->name); row("Workunit", "workunitid\">" . wu_name_by_id($result->workunitid) . " [$result->workunitid]" ); row("Server state", server_state_string($result->server_state)." [$result->server_state]"); row("Outcome", outcome_string($result->outcome)." [$result->outcome]"); row("Client state", client_state_string($result->client_state)." [$result->client_state]"); row("Exit status", exit_status_string($result)); row("Host ID", "hostid\">" . host_name_by_id($result->hostid) . " [$result->hostid]"); row("User ID", "userid\">" . user_name_by_id($result->userid) . " [$result->userid]"); row("Report deadline", time_str($result->report_deadline)); row("CPU time", $result->cpu_time); row("XML doc in", "

".htmlspecialchars($result->xml_doc_in)."
"); row("XML doc out", "
".htmlspecialchars($result->xml_doc_out)."
"); row("stderr out", "
".htmlspecialchars($result->stderr_out)."
"); if($error=stderr_error_string($result->stderr_out)) { row("error in stderr out", $error); } row("Batch", $result->batch); row("File delete state", file_delete_state_str($result->file_delete_state)." [$result->file_delete_state]"); row("Validate state", validate_state_str($result->validate_state)." [$result->validate_state]"); row("claimed credit", $result->claimed_credit); row("Granted credit", $result->granted_credit); row("Application", "appid\">".app_name_by_id($result->appid).""); row("App version", "appid&clauses=version_num%3D$result->app_version_num\">".$result->app_version_num.""); row("Random",$result->random); row("Opaque",$result->opaque); row("Teamid",$result->teamid); row("Priority",$result->priority); end_table(); echo "
"; echo "name\">GREP LOGS FOR THIS RESULT"; echo "
"; echo "

"; } function result_short_header() { echo " result ID WU ID server
state outcome validate
state delete
state exit
status host
(user) client
ver received or deadline CPU
hours claimed
credit granted
credit "; } function show_result_short($result) { $ss = server_state_string($result->server_state); $oc = outcome_string($result->outcome); $vs = validate_state_str($result->validate_state); if ($result->outcome == 3) { $cs = client_state_string($result->client_state); $oc = "$oc ($cs)"; } if ($result->received_time) $received = time_str($result->received_time); else { // result has not been received yet, so show report deadline either // in green if in the future or in red if in the past. $timenow=time(); if ($result->report_deadline>=$timenow) { $colortag=""; } else { $colortag=""; } $received = $colortag . time_str($result->report_deadline) . ""; } $version = $result->app_version_num; $outcome_color = outcome_color($result->outcome); $validate_color = validate_color($result->validate_state); $host_user = host_user_link($result->hostid); $cpu_hours = sprintf("%.1f",$result->cpu_time / 3600); $claimed_credit = credit_str($result->claimed_credit); $granted_credit = credit_str($result->granted_credit); $delete_state = file_delete_state_str($result->file_delete_state); echo " id>$result->id workunitid>$result->workunitid $ss $oc $vs $delete_state ", exit_status_string($result), " $host_user $version $received $cpu_hours $claimed_credit $granted_credit "; } 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); row("Email address", $user->email_addr); row("Country", $user->country); row("Postal code", $user->postal_code); row("Total credit", $user->total_credit); row("Average credit", $user->expavg_credit); row("Last average time", time_str($user->expavg_time)); row("Default venue", $user->venue); row("Hosts", "id&detail=low>click"); row("Cross project ID", $user->cross_project_id); end_table(); } function team_type_string($s) { switch ($s) { case 1: return "Unclassified"; case 2: return "Company"; case 3: return "Primary school"; case 4: return "Secondary school"; case 5: return "Junior college"; case 6: return "University or department"; case 7: return "Government agency"; default: return "Unknown"; } } function show_team($team) { start_table(); row("ID", $team->id); row("Team Founder", "userid>" . user_name_by_id($team->userid) . ""); row("Name", $team->name); row("Name (HTML Formatted)", "

" . htmlspecialchars($team->name_html) . "
" ); row("Url", "url>" . $team->url . ""); row("Type", team_type_string($team->type)); row("Description", $team->description); row("", "id>List All Members"); end_table(); } function team_name_by_id($teamid) { $result = mysql_query("select * from team where id = $teamid"); $team = mysql_fetch_object($result); return $team->name; } function user_name_by_id($user_id) { $result = mysql_query("select * from user where id = $user_id"); $user = mysql_fetch_object($result); return $user->name; } function app_name_by_id($appid) { $result = mysql_query("select * from app where id = $appid"); $app = mysql_fetch_object($result); return $app->name; } function wu_name_by_id($workunitid) { $result = mysql_query("select * from workunit where id = $workunitid"); $wu = mysql_fetch_object($result); return $wu->name; } function platform_name_by_id($platformid) { $result = mysql_query("select * from platform where id = $platformid"); $plat = mysql_fetch_object($result); return $plat->name; } function host_name_by_id($hostid) { $result = mysql_query("select * from host where id = $hostid"); $host = mysql_fetch_object($result); if (!strlen($host->domain_name) && !strlen($host->last_ip_addr)) { return "(blank)"; } else { return $host->domain_name . " (" . $host->last_ip_addr . ")"; } } ?>