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($$$$$;$) ...@@ -3197,7 +3197,7 @@ sub GatherSwapStats($$$$$;$)
my ($gid, $exptidx, $rsrcidx, $lastrsrc, $lastswapuid) = my ($gid, $exptidx, $rsrcidx, $lastrsrc, $lastswapuid) =
$query_result->fetchrow_array; $query_result->fetchrow_array;
$lastswapuid = $uid $lastswapuid = $uid
if (!defined($lastswapuid)); if (!defined($lastswapuid) || $lastswapuid eq "");
# #
# A non-zero ecode indicates error. If op is a preload/swapin/start/modify # A non-zero ecode indicates error. If op is a preload/swapin/start/modify
...@@ -3434,8 +3434,10 @@ sub GatherSwapStats($$$$$;$) ...@@ -3434,8 +3434,10 @@ sub GatherSwapStats($$$$$;$)
# #
logit: logit:
DBQueryWarn("insert into testbed_stats ". DBQueryWarn("insert into testbed_stats ".
"(idx, tstamp, exptidx, rsrcidx, action, exitcode) ". "(idx, uid, tstamp, exptidx, rsrcidx, ".
"values (0, now(), $exptidx, $rsrcidx, '$mode', $ecode)"); " action, exitcode) ".
"values (0, '$uid', now(), $exptidx, $rsrcidx, ".
" '$mode', $ecode)");
} }
# #
......
...@@ -1141,6 +1141,7 @@ CREATE TABLE testbed_stats ( ...@@ -1141,6 +1141,7 @@ CREATE TABLE testbed_stats (
rsrcidx int(10) unsigned NOT NULL default '0', rsrcidx int(10) unsigned NOT NULL default '0',
action varchar(16) NOT NULL default '', action varchar(16) NOT NULL default '',
exitcode tinyint(3) default '0', exitcode tinyint(3) default '0',
uid varchar(8) NOT NULL default '',
PRIMARY KEY (idx) PRIMARY KEY (idx)
) TYPE=MyISAM; ) TYPE=MyISAM;
......
...@@ -665,3 +665,24 @@ last_net_act,last_cpu_act,last_ext_act); ...@@ -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 1.155: Bring the definition for the roottag column into sync with what's in
the database on boss - no database changes required. 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") { ...@@ -82,7 +82,6 @@ if ($showby == "user") {
else else
$which = $uid; $which = $uid;
$wclause = "where s.creator='$which'"; $wclause = "where s.creator='$which'";
$records = 100;
} }
elseif ($showby == "project") { elseif ($showby == "project") {
if (! $which) { if (! $which) {
...@@ -93,7 +92,6 @@ elseif ($showby == "project") { ...@@ -93,7 +92,6 @@ elseif ($showby == "project") {
"project $which!", 1); "project $which!", 1);
} }
$wclause = "where s.pid='$which'"; $wclause = "where s.pid='$which'";
$records = 100;
} }
elseif ($showby == "expt") { elseif ($showby == "expt") {
if (!$which) { if (!$which) {
...@@ -122,7 +120,6 @@ elseif ($showby == "expt") { ...@@ -122,7 +120,6 @@ elseif ($showby == "expt") {
} }
} }
$wclause = "where t.exptidx='$which'"; $wclause = "where t.exptidx='$which'";
$records = 100;
} }
elseif ($showby == "all") { elseif ($showby == "all") {
if ($which) { if ($which) {
...@@ -146,7 +143,6 @@ elseif ($showby == "all") { ...@@ -146,7 +143,6 @@ elseif ($showby == "all") {
} }
$wclause = "where $wclause 0"; $wclause = "where $wclause 0";
} }
$records = 100;
} }
else { else {
USERERROR("Bad page arguments!", 1); USERERROR("Bad page arguments!", 1);
......
...@@ -147,6 +147,10 @@ function showsummary ($showby, $sortby) { ...@@ -147,6 +147,10 @@ function showsummary ($showby, $sortby) {
"$wclause ". "$wclause ".
"order by $order"); "order by $order");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No summary stats of interest!", 1);
}
# #
# Gather some totals first. # Gather some totals first.
# #
...@@ -261,7 +265,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -261,7 +265,7 @@ function showrange ($showby, $sortby, $range) {
# First get current swapped in experiments. # First get current swapped in experiments.
# #
$query_result = $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) ". " UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(e.expt_swapped) ".
" as swapseconds, ". " as swapseconds, ".
" count(*) as pnodes ". " count(*) as pnodes ".
...@@ -275,7 +279,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -275,7 +279,7 @@ function showrange ($showby, $sortby, $range) {
while ($row = mysql_fetch_assoc($query_result)) { while ($row = mysql_fetch_assoc($query_result)) {
$pid = $row["pid"]; $pid = $row["pid"];
$eid = $row["eid"]; $eid = $row["eid"];
$uid = $row["creator"]; $uid = $row["swapper"];
$swapseconds = $row["swapseconds"]; $swapseconds = $row["swapseconds"];
$pnodes = $row["pnodes"]; $pnodes = $row["pnodes"];
...@@ -295,7 +299,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -295,7 +299,7 @@ function showrange ($showby, $sortby, $range) {
} }
$query_result = $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, ". " r1.pnodes as pnodes1,r2.pnodes as pnodes2, ".
" UNIX_TIMESTAMP(t.tstamp) as ttstamp ". " UNIX_TIMESTAMP(t.tstamp) as ttstamp ".
" from testbed_stats as t ". " from testbed_stats as t ".
...@@ -316,7 +320,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -316,7 +320,7 @@ function showrange ($showby, $sortby, $range) {
while ($row = mysql_fetch_assoc($query_result)) { while ($row = mysql_fetch_assoc($query_result)) {
$pid = $row["pid"]; $pid = $row["pid"];
$eid = $row["eid"]; $eid = $row["eid"];
$uid = $row["creator"]; $uid = $row["uid"];
$tstamp = $row["ttstamp"]; $tstamp = $row["ttstamp"];
$action = $row["action"]; $action = $row["action"];
$pnodes = $row["pnodes1"]; $pnodes = $row["pnodes1"];
...@@ -362,7 +366,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -362,7 +366,7 @@ function showrange ($showby, $sortby, $range) {
# no start/swapin event was returned. Add a record for it. # no start/swapin event was returned. Add a record for it.
# #
$diff = $tstamp - $spanstart; $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") { if ($action == "swapmod") {
# A pain. We need the number of pnodes for the original # A pain. We need the number of pnodes for the original
# version of the experiment, not the new version. # version of the experiment, not the new version.
...@@ -380,6 +384,9 @@ function showrange ($showby, $sortby, $range) { ...@@ -380,6 +384,9 @@ function showrange ($showby, $sortby, $range) {
# Basically, start the clock ticking again with the new # Basically, start the clock ticking again with the new
# number of pnodes. # number of pnodes.
if ($action == "swapmod") { 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, $expt_start["$pid:$eid"] = array('pnodes' => $pnodes,
'uid' => $uid, 'uid' => $uid,
'pid' => $pid, '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