Commit fb9a442d authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add uid to testbed_stats so that we can better track events when

experiments are operated on by people other than the original creator.
The uid is currently a text field, but will need to change at some
point.
parent 72f0936a
......@@ -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)");
}
#
......
......@@ -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;
......
......@@ -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";
}
......@@ -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);
......
......@@ -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<br>\n";
#echo "F $pid $eid $uid $action $diff $pnodes $pnodes2<br>\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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment