diff --git a/db/libdb.pm.in b/db/libdb.pm.in
index b6d9e22a210471c0abc17d6bcb55d36503b345f7..21152bbd951eacf4af59a52031184b1f6880a6da 100644
--- a/db/libdb.pm.in
+++ b/db/libdb.pm.in
@@ -3197,7 +3197,7 @@ sub GatherSwapStats($$$$$;$)
my ($gid, $exptidx, $rsrcidx, $lastrsrc, $lastswapuid) =
$query_result->fetchrow_array;
$lastswapuid = $uid
- if (!defined($lastswapuid));
+ if (!defined($lastswapuid) || $lastswapuid eq "");
#
# A non-zero ecode indicates error. If op is a preload/swapin/start/modify
@@ -3434,8 +3434,10 @@ sub GatherSwapStats($$$$$;$)
#
logit:
DBQueryWarn("insert into testbed_stats ".
- "(idx, tstamp, exptidx, rsrcidx, action, exitcode) ".
- "values (0, now(), $exptidx, $rsrcidx, '$mode', $ecode)");
+ "(idx, uid, tstamp, exptidx, rsrcidx, ".
+ " action, exitcode) ".
+ "values (0, '$uid', now(), $exptidx, $rsrcidx, ".
+ " '$mode', $ecode)");
}
#
diff --git a/sql/database-create.sql b/sql/database-create.sql
index dc584467a499841b1dfbf91993683b3c8c41d1c8..0c1eb0be3f8ef3c1c3a4b8e2e505dcb0c75b4751 100644
--- a/sql/database-create.sql
+++ b/sql/database-create.sql
@@ -1141,6 +1141,7 @@ CREATE TABLE testbed_stats (
rsrcidx int(10) unsigned NOT NULL default '0',
action varchar(16) NOT NULL default '',
exitcode tinyint(3) default '0',
+ uid varchar(8) NOT NULL default '',
PRIMARY KEY (idx)
) TYPE=MyISAM;
diff --git a/sql/database-migrate.txt b/sql/database-migrate.txt
index 330b27cadb26e1497e6855194089a2f25fc8d0c1..c77559148c365834384c4ca80c02f2e20a2bc5be 100644
--- a/sql/database-migrate.txt
+++ b/sql/database-migrate.txt
@@ -665,3 +665,24 @@ last_net_act,last_cpu_act,last_ext_act);
1.155: Bring the definition for the roottag column into sync with what's in
the database on boss - no database changes required.
+
+1.156: Add uid to testbed_stats table:
+
+ alter table testbed_stats add uid varchar(8) NOT NULL
+ default '' after exitcode;
+
+ Need to init the table. For lack of better info, use the
+ experiment creator for each record. Turns out there are just a
+ few cases where this is not true.
+
+ my $query_result =
+ DBQueryWarn("select t.idx,s.creator,t.action ".
+ " from testbed_stats as t ".
+ "left join experiment_stats as s on ".
+ " s.exptidx=t.exptidx ".
+ "where t.uid='' ".
+ "order by t.tstamp");
+
+ while (($idx,$creator) = $query_result->fetchrow_array()) {
+ print "update testbed_stats set uid='$creator' where idx=$idx;\n";
+ }
diff --git a/www/showstats.php3 b/www/showstats.php3
index a453702d62e72eced9dce1e08c89916257cc7a91..9504eea9f77328d9037733d302478b04bc556732 100644
--- a/www/showstats.php3
+++ b/www/showstats.php3
@@ -82,7 +82,6 @@ if ($showby == "user") {
else
$which = $uid;
$wclause = "where s.creator='$which'";
- $records = 100;
}
elseif ($showby == "project") {
if (! $which) {
@@ -93,7 +92,6 @@ elseif ($showby == "project") {
"project $which!", 1);
}
$wclause = "where s.pid='$which'";
- $records = 100;
}
elseif ($showby == "expt") {
if (!$which) {
@@ -122,7 +120,6 @@ elseif ($showby == "expt") {
}
}
$wclause = "where t.exptidx='$which'";
- $records = 100;
}
elseif ($showby == "all") {
if ($which) {
@@ -146,7 +143,6 @@ elseif ($showby == "all") {
}
$wclause = "where $wclause 0";
}
- $records = 100;
}
else {
USERERROR("Bad page arguments!", 1);
diff --git a/www/showsumstats.php3 b/www/showsumstats.php3
index 103368e9f8d5891edd5ec8762fb11eadb41ebce5..fdab07d71f1074653d9b311c380d6ecc6bc53118 100644
--- a/www/showsumstats.php3
+++ b/www/showsumstats.php3
@@ -147,6 +147,10 @@ function showsummary ($showby, $sortby) {
"$wclause ".
"order by $order");
+ if (mysql_num_rows($query_result) == 0) {
+ USERERROR("No summary stats of interest!", 1);
+ }
+
#
# Gather some totals first.
#
@@ -261,7 +265,7 @@ function showrange ($showby, $sortby, $range) {
# First get current swapped in experiments.
#
$query_result =
- DBQueryFatal("select r.pid,r.eid,e.expt_head_uid as creator, ".
+ DBQueryFatal("select r.pid,r.eid,e.expt_swap_uid as swapper, ".
" UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(e.expt_swapped) ".
" as swapseconds, ".
" count(*) as pnodes ".
@@ -275,7 +279,7 @@ function showrange ($showby, $sortby, $range) {
while ($row = mysql_fetch_assoc($query_result)) {
$pid = $row["pid"];
$eid = $row["eid"];
- $uid = $row["creator"];
+ $uid = $row["swapper"];
$swapseconds = $row["swapseconds"];
$pnodes = $row["pnodes"];
@@ -295,7 +299,7 @@ function showrange ($showby, $sortby, $range) {
}
$query_result =
- DBQueryFatal("select s.pid,s.eid,s.creator,t.action, ".
+ DBQueryFatal("select s.pid,s.eid,t.uid,t.action, ".
" r1.pnodes as pnodes1,r2.pnodes as pnodes2, ".
" UNIX_TIMESTAMP(t.tstamp) as ttstamp ".
" from testbed_stats as t ".
@@ -316,7 +320,7 @@ function showrange ($showby, $sortby, $range) {
while ($row = mysql_fetch_assoc($query_result)) {
$pid = $row["pid"];
$eid = $row["eid"];
- $uid = $row["creator"];
+ $uid = $row["uid"];
$tstamp = $row["ttstamp"];
$action = $row["action"];
$pnodes = $row["pnodes1"];
@@ -362,7 +366,7 @@ function showrange ($showby, $sortby, $range) {
# no start/swapin event was returned. Add a record for it.
#
$diff = $tstamp - $spanstart;
- #echo "$pid $eid $uid $action $diff $pnodes $pnodes2
\n";
+ #echo "F $pid $eid $uid $action $diff $pnodes $pnodes2
\n";
if ($action == "swapmod") {
# A pain. We need the number of pnodes for the original
# version of the experiment, not the new version.
@@ -380,6 +384,9 @@ function showrange ($showby, $sortby, $range) {
# Basically, start the clock ticking again with the new
# number of pnodes.
if ($action == "swapmod") {
+ # Yuck, we redefined uid above, but we want to start the
+ # new record for the current swapper.
+ $uid = $row["uid"];
$expt_start["$pid:$eid"] = array('pnodes' => $pnodes,
'uid' => $uid,
'pid' => $pid,