Commit 3b4626e7 authored by Leigh Stoller's avatar Leigh Stoller

Add swapper to the project Usage() listing so we can correlate usage

within a project with reservations active during an experiment.
parent dbb97d05
......@@ -1005,21 +1005,23 @@ sub Usage($$$)
my $query_result =
DBQueryWarn("(select e.eid,s.rsrcidx,s.nonlocal_id,s.slice_uuid, ".
" UNIX_TIMESTAMP(s.swapin_last),0,n.type,".
" count(n.type) ".
" UNIX_TIMESTAMP(s.swapin_last),0,".
" e.swapper_idx,n.type,count(n.type) ".
" from experiments as e ".
"left join experiment_stats as s on ".
" s.exptidx=e.idx ".
"left join reserved as r on r.exptidx=e.idx ".
"left join nodes as n on n.node_id=r.node_id ".
"where e.pid_idx='$pid_idx' and e.state='active' ".
" and UNIX_TIMESTAMP(s.swapin_last) < $end ".
"group by e.eid,s.rsrcidx,s.nonlocal_id,s.slice_uuid, ".
" UNIX_TIMESTAMP(s.swapin_last),n.type ".
" UNIX_TIMESTAMP(s.swapin_last), ".
" e.swapper_idx,n.type ".
"order by s.swapin_last desc) ".
"union ".
"(select s.eid,r.idx,s.nonlocal_id,s.slice_uuid, ".
" r.swapin_time,r.swapout_time,n.type, ".
" count(n.type) ".
" r.swapin_time,r.swapout_time, ".
" h.uid_idx,n.type,count(n.type) ".
" from experiment_resources as r ".
"left join experiment_stats as s on ".
" s.exptidx=r.exptidx ".
......@@ -1038,7 +1040,8 @@ sub Usage($$$)
" (r.swapout_time > $start and ".
" r.swapout_time < $end)) ".
"group by s.eid,r.idx,s.nonlocal_id,s.slice_uuid, ".
" r.swapin_time,r.swapout_time,n.type ".
" r.swapin_time,r.swapout_time, ".
" h.uid_idx,n.type ".
"order by r.swapin_time desc) "
);
......@@ -1049,7 +1052,7 @@ sub Usage($$$)
my $lastin = 0;
while (my ($eid,$idx,$urn,$slice_uuid,
$swapin_time,$swapout_time,$type,$count) =
$swapin_time,$swapout_time,$swapper_idx,$type,$count) =
$query_result->fetchrow_array()) {
# In the emulab-ops project, we nalloc nodes to experiments that
# have never been swapped in (like hwdown).
......@@ -1058,6 +1061,13 @@ sub Usage($$$)
# No phys nodes.
next
if ($count == 0 || !defined($type));
my ($swapper_urn, $swapper_uid);
my $user = User->Lookup($swapper_idx);
if (defined($user)) {
$swapper_urn = $user->nonlocalurn()->asString();
$swapper_uid = $user->uid();
}
# The order by clause is important.
if ($swapin_time != $lastin) {
......@@ -1066,6 +1076,8 @@ sub Usage($$$)
"slice_uuid" => $slice_uuid || "",
"start" => $swapin_time,
"end" => $swapout_time || "",
"user_uid" => $swapper_uid,
"user_urn" => $swapper_urn,
"types" => {$type => {"count" => $count}}});
$lastin = $swapin_time;
next;
......
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