2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
2007-09-17 19:15:01 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2004-06-21 20:14:38 +00:00
|
|
|
function result_claimed_credit_string($result, $string_to_show) {
|
|
|
|
if ($result->server_state <> 5) return "---";
|
|
|
|
switch($result->outcome) {
|
|
|
|
case 1: return $string_to_show; //Success
|
|
|
|
case 2: return "---"; //Couldn't send
|
2007-07-11 17:14:02 +00:00
|
|
|
case 3: if ($result->exit_status <> -221) {
|
|
|
|
return $string_to_show; //Client error
|
|
|
|
} else return "---"; // Aborted by server
|
2004-06-21 20:14:38 +00:00
|
|
|
case 4: return "---"; //No reply
|
|
|
|
case 5: return "---"; //Didn't need
|
2004-12-01 23:20:12 +00:00
|
|
|
case 6: return "---"; // Validate error
|
2006-07-06 17:30:03 +00:00
|
|
|
case 7: return "---"; // client detached
|
2004-06-21 20:14:38 +00:00
|
|
|
default: return $string_to_show;
|
|
|
|
}
|
2004-04-04 02:59:42 +00:00
|
|
|
}
|
|
|
|
|
2004-06-21 20:14:38 +00:00
|
|
|
function result_granted_credit_string($result, $string_to_show) {
|
|
|
|
if ($result->server_state <> 5) return "---";
|
|
|
|
switch($result->outcome) {
|
|
|
|
case 1: //Success
|
2004-12-14 00:57:03 +00:00
|
|
|
switch ($result->validate_state) {
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
return "pending";
|
2004-06-21 20:14:38 +00:00
|
|
|
}
|
2004-12-14 00:57:03 +00:00
|
|
|
return $string_to_show;
|
2004-06-21 20:14:38 +00:00
|
|
|
case 2: return "---"; //Couldn't send
|
2004-10-15 23:46:24 +00:00
|
|
|
case 3: return "---"; //Client error
|
2004-06-21 20:14:38 +00:00
|
|
|
case 4: return "---"; //No reply
|
|
|
|
case 5: return "---"; //Didn't need
|
2004-12-01 23:20:12 +00:00
|
|
|
case 6: return "---"; //Validate error
|
2006-07-06 17:30:03 +00:00
|
|
|
case 7: return "---"; // client detached
|
2004-06-21 20:14:38 +00:00
|
|
|
default: return $string_to_show;
|
|
|
|
}
|
2004-04-04 02:59:42 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 17:14:02 +00:00
|
|
|
function result_server_state_string($result) {
|
|
|
|
switch($result->server_state) {
|
2004-02-02 23:34:39 +00:00
|
|
|
case 1: return "Inactive";
|
|
|
|
case 2: return "Unsent";
|
|
|
|
case 4: return "In Progress";
|
|
|
|
case 5: return "Over";
|
|
|
|
}
|
2004-06-21 20:14:38 +00:00
|
|
|
return "Unknown";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 17:14:02 +00:00
|
|
|
function result_outcome_string($result) {
|
|
|
|
switch($result->outcome) {
|
2004-02-02 23:34:39 +00:00
|
|
|
case 1: return "Success";
|
|
|
|
case 2: return "Couldn't send";
|
2007-07-11 17:14:02 +00:00
|
|
|
case 3: if ($result->exit_status <> -221) {
|
|
|
|
return "Client error";
|
|
|
|
} else return "Redundant result";
|
2004-02-02 23:34:39 +00:00
|
|
|
case 4: return "No reply";
|
|
|
|
case 5: return "Didn't need";
|
2004-12-01 23:20:12 +00:00
|
|
|
case 6: return "Validate error";
|
2006-07-06 17:30:03 +00:00
|
|
|
case 7: return "Client detached";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2004-06-21 20:14:38 +00:00
|
|
|
return "Unknown";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 17:14:02 +00:00
|
|
|
function result_client_state_string($result) {
|
|
|
|
switch($result->client_state) {
|
2004-02-02 23:34:39 +00:00
|
|
|
case 0: return "New";
|
|
|
|
case 1: return "Downloading";
|
2006-05-25 20:10:08 +00:00
|
|
|
case 2: return "Computing";
|
|
|
|
case 3: return "Compute error";
|
2004-02-02 23:34:39 +00:00
|
|
|
case 4: return "Uploading";
|
|
|
|
case 5: return "Done";
|
2007-07-11 17:14:02 +00:00
|
|
|
case 6: if ($result->exit_status <> -221) {
|
|
|
|
return "Aborted by user";
|
|
|
|
} else return "Cancelled by server";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-11 17:14:02 +00:00
|
|
|
function validate_state_str($result) {
|
|
|
|
switch($result->validate_state) {
|
2004-02-02 23:34:39 +00:00
|
|
|
case 0: return "Initial";
|
|
|
|
case 1: return "Valid";
|
2007-07-11 17:14:02 +00:00
|
|
|
case 2: if ($result->exit_status <> -221) {
|
|
|
|
return "Invalid";
|
|
|
|
} else return "Not necessary";
|
2005-02-08 00:39:05 +00:00
|
|
|
case 3: return "Workunit error - check skipped";
|
2004-12-14 00:57:03 +00:00
|
|
|
case 4: return "Checked, but no consensus yet";
|
2007-10-04 17:30:28 +00:00
|
|
|
case 5: return "Task was reported too late to validate";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2004-06-21 20:14:38 +00:00
|
|
|
return "Unknown";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2004-12-15 23:50:00 +00:00
|
|
|
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 error results ";
|
|
|
|
$s -= 2;
|
|
|
|
}
|
|
|
|
if ($s & 4) {
|
|
|
|
$x = $x."Too many success results ";
|
|
|
|
$s -= 4;
|
|
|
|
}
|
|
|
|
if ($s & 8) {
|
|
|
|
$x = $x."Too many total results ";
|
|
|
|
$s -= 8;
|
|
|
|
}
|
|
|
|
if ($s & 16) {
|
|
|
|
$x = $x."Cancelled ";
|
|
|
|
$s -= 16;
|
|
|
|
}
|
|
|
|
if ($s) {
|
|
|
|
$x = $x."Unrecognized Error: $s ";
|
|
|
|
}
|
|
|
|
if (strlen($x)) {
|
|
|
|
} else {
|
|
|
|
$x="<br>";
|
|
|
|
}
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
function result_table_start($show_wu_link, $show_host_link, $show_result_link) {
|
|
|
|
start_table();
|
|
|
|
echo "
|
|
|
|
<tr>
|
|
|
|
";
|
|
|
|
if ($show_result_link) {
|
2007-10-04 17:30:28 +00:00
|
|
|
echo "<th>Task ID<br><span class=\"smalltext\">click for details</span></th>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
if ($show_wu_link) {
|
2007-09-01 19:43:24 +00:00
|
|
|
echo "<th>Work unit ID<br><span class=\"smalltext\">click for details</span></th>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
if ($show_host_link) {
|
2005-02-07 06:24:14 +00:00
|
|
|
echo "<th>Computer</th>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
echo "
|
|
|
|
<th>Sent</th>
|
2004-12-15 23:50:00 +00:00
|
|
|
<th>Time reported
|
|
|
|
<br>or deadline
|
2007-09-01 19:43:24 +00:00
|
|
|
<br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_time\">explain</a></span>
|
2004-12-15 23:50:00 +00:00
|
|
|
</th>
|
2004-02-02 23:34:39 +00:00
|
|
|
<th>Server state
|
2007-09-01 19:43:24 +00:00
|
|
|
<br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_server_state\">explain</a></span>
|
2004-02-02 23:34:39 +00:00
|
|
|
</th>
|
|
|
|
<th>Outcome
|
2007-09-01 19:43:24 +00:00
|
|
|
<br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_outcome\">explain</a></span>
|
2004-02-02 23:34:39 +00:00
|
|
|
</th>
|
|
|
|
<th>Client state
|
2007-09-01 19:43:24 +00:00
|
|
|
<br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_client_state\">explain</a></span>
|
2004-02-02 23:34:39 +00:00
|
|
|
</th>
|
|
|
|
<th>CPU time (sec)</th>
|
|
|
|
<th>claimed credit</th>
|
|
|
|
<th>granted credit</th>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2006-02-20 07:55:32 +00:00
|
|
|
// was result invalid or timed out?
|
|
|
|
//
|
|
|
|
function bad_result($result) {
|
|
|
|
if ($result->validate_state == 2) return true;
|
|
|
|
if (!$result->received_time && ($result->report_deadline < time())) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
function show_result_row(
|
|
|
|
$result, $show_wu_link, $show_host_link, $show_result_link
|
|
|
|
) {
|
|
|
|
$s = time_str($result->sent_time);
|
2004-12-15 23:50:00 +00:00
|
|
|
// if result has been received, show the received time,
|
|
|
|
// else show the reporting deadline in green if in the future
|
|
|
|
// and in red if in the past.
|
|
|
|
//
|
|
|
|
if ($result->received_time) {
|
2004-12-01 23:20:12 +00:00
|
|
|
$r = time_str($result->received_time);
|
2004-12-15 23:50:00 +00:00
|
|
|
} else if ($result->report_deadline) {
|
|
|
|
if ($result->report_deadline>time()) {
|
2004-12-01 23:20:12 +00:00
|
|
|
$r = "<font color='33cc33'>" . time_str($result->report_deadline) . "</font>";
|
2004-12-14 00:57:03 +00:00
|
|
|
} else {
|
2004-12-01 23:20:12 +00:00
|
|
|
$r = "<font color='ff3333'>" . time_str($result->report_deadline) . "</font>";
|
2004-12-14 00:57:03 +00:00
|
|
|
}
|
2004-12-15 23:50:00 +00:00
|
|
|
} else {
|
|
|
|
$r = "---";
|
2004-12-01 23:20:12 +00:00
|
|
|
}
|
2007-07-11 17:14:02 +00:00
|
|
|
$ss = result_server_state_string($result);
|
|
|
|
$out = result_outcome_string($result);
|
|
|
|
$cl = result_client_state_string($result);
|
2004-04-04 02:59:42 +00:00
|
|
|
$result_claimed_credit = format_credit($result->claimed_credit);
|
|
|
|
$result_granted_credit = format_credit($result->granted_credit);
|
2004-06-21 20:14:38 +00:00
|
|
|
$result_claimed_credit = result_claimed_credit_string($result, $result_claimed_credit);
|
|
|
|
$result_granted_credit = result_granted_credit_string($result, $result_granted_credit);
|
2006-02-20 07:55:32 +00:00
|
|
|
if (bad_result($result)) {
|
|
|
|
echo "<tr class=invalid_result>";
|
|
|
|
} else {
|
|
|
|
echo "<tr>";
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
if ($show_result_link) {
|
2006-11-15 15:41:02 +00:00
|
|
|
echo "<td><a href=\"result.php?resultid=$result->id\" title=\"Name: ".$result->name."\">$result->id</a></td>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
if ($show_wu_link) {
|
2004-12-18 17:27:03 +00:00
|
|
|
echo "<td><a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a></td>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
if ($show_host_link) {
|
2004-02-05 21:35:48 +00:00
|
|
|
echo "<td>", host_link($result->hostid), "</td>\n";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2004-06-21 20:14:38 +00:00
|
|
|
if ($result->server_state <> 5) {
|
|
|
|
$cpu_time = "---";
|
|
|
|
} else {
|
|
|
|
$cpu_time = number_format($result->cpu_time, 2);
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
echo "
|
|
|
|
<td>$s</td>
|
|
|
|
<td>$r</td>
|
|
|
|
<td>$ss</td>
|
|
|
|
<td>$out</td>
|
|
|
|
<td>$cl</td>
|
2004-06-21 20:14:38 +00:00
|
|
|
<td>$cpu_time</td>
|
2004-02-02 23:34:39 +00:00
|
|
|
<td>$result_claimed_credit</td>
|
|
|
|
<td>$result_granted_credit</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2004-10-29 20:22:22 +00:00
|
|
|
function version_string($version_num) {
|
|
|
|
if (!$version_num) {
|
2004-02-02 23:34:39 +00:00
|
|
|
return '---';
|
|
|
|
} else {
|
2004-10-29 20:22:22 +00:00
|
|
|
return sprintf("%.2f", $version_num/100);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function exit_status_string($result) {
|
|
|
|
$x = $result->exit_status;
|
|
|
|
if ($x == 0) {
|
|
|
|
$y = parse_element($result->stderr_out, "<exit_status>");
|
|
|
|
if ($y) {
|
|
|
|
$x = (int)$y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sprintf("%d (0x%x)", $x, $x);
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_result($result) {
|
|
|
|
start_table();
|
2007-10-04 17:30:28 +00:00
|
|
|
row2("Task ID", $result->id);
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Name", $result->name);
|
2004-12-18 17:27:03 +00:00
|
|
|
row2("Workunit", "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Created", time_str($result->create_time));
|
|
|
|
row2("Sent", time_str($result->sent_time));
|
|
|
|
row2("Received", time_str($result->received_time));
|
2007-07-11 17:14:02 +00:00
|
|
|
row2("Server state", result_server_state_string($result));
|
|
|
|
row2("Outcome", result_outcome_string($result));
|
|
|
|
row2("Client state", result_client_state_string($result));
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Exit status", exit_status_string($result));
|
2005-02-07 06:24:14 +00:00
|
|
|
row2("Computer ID", host_link($result->hostid));
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Report deadline", time_str($result->report_deadline));
|
|
|
|
row2("CPU time", $result->cpu_time);
|
|
|
|
row2("stderr out", "<pre>".htmlspecialchars($result->stderr_out)."</pre>");
|
2007-09-17 19:15:01 +00:00
|
|
|
row2("Validate state", validate_state_str($result));
|
2004-10-29 20:22:22 +00:00
|
|
|
row2("Claimed credit", $result->claimed_credit);
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Granted credit", $result->granted_credit);
|
2004-10-29 20:22:22 +00:00
|
|
|
row2("application version", version_string($result->app_version_num));
|
2004-02-02 23:34:39 +00:00
|
|
|
end_table();
|
|
|
|
}
|
|
|
|
|
2006-05-04 04:29:28 +00:00
|
|
|
function show_result_navigation(
|
|
|
|
$clause, $number_of_results, $offset, $results_per_page
|
|
|
|
) {
|
|
|
|
echo "<br><center>";
|
|
|
|
if ($offset >= $results_per_page) {
|
|
|
|
$offset_p = $offset-$results_per_page;
|
|
|
|
echo "<a href=results.php?$clause&offset=$offset_p>Previous $results_per_page</a>";
|
|
|
|
}
|
|
|
|
if (($offset >= $results_per_page) && ($number_of_results > $results_per_page)) {
|
|
|
|
echo " | ";
|
|
|
|
}
|
|
|
|
if ($number_of_results > $results_per_page) {
|
|
|
|
$offset_n = $offset+$results_per_page;
|
|
|
|
echo "<a href=results.php?$clause&offset=$offset_n>Next $results_per_page</a></center><br>";
|
|
|
|
} else {
|
|
|
|
echo "</center><br><br>";
|
|
|
|
}
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|