Commit 3b4626e7 authored by Leigh B Stoller's avatar Leigh B 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($$$) ...@@ -1005,21 +1005,23 @@ sub Usage($$$)
my $query_result = my $query_result =
DBQueryWarn("(select e.eid,s.rsrcidx,s.nonlocal_id,s.slice_uuid, ". DBQueryWarn("(select e.eid,s.rsrcidx,s.nonlocal_id,s.slice_uuid, ".
" UNIX_TIMESTAMP(s.swapin_last),0,n.type,". " UNIX_TIMESTAMP(s.swapin_last),0,".
" count(n.type) ". " e.swapper_idx,n.type,count(n.type) ".
" from experiments as e ". " from experiments as e ".
"left join experiment_stats as s on ". "left join experiment_stats as s on ".
" s.exptidx=e.idx ". " s.exptidx=e.idx ".
"left join reserved as r on r.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 ". "left join nodes as n on n.node_id=r.node_id ".
"where e.pid_idx='$pid_idx' and e.state='active' ". "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, ". "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) ". "order by s.swapin_last desc) ".
"union ". "union ".
"(select s.eid,r.idx,s.nonlocal_id,s.slice_uuid, ". "(select s.eid,r.idx,s.nonlocal_id,s.slice_uuid, ".
" r.swapin_time,r.swapout_time,n.type, ". " r.swapin_time,r.swapout_time, ".
" count(n.type) ". " h.uid_idx,n.type,count(n.type) ".
" from experiment_resources as r ". " from experiment_resources as r ".
"left join experiment_stats as s on ". "left join experiment_stats as s on ".
" s.exptidx=r.exptidx ". " s.exptidx=r.exptidx ".
...@@ -1038,7 +1040,8 @@ sub Usage($$$) ...@@ -1038,7 +1040,8 @@ sub Usage($$$)
" (r.swapout_time > $start and ". " (r.swapout_time > $start and ".
" r.swapout_time < $end)) ". " r.swapout_time < $end)) ".
"group by s.eid,r.idx,s.nonlocal_id,s.slice_uuid, ". "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) " "order by r.swapin_time desc) "
); );
...@@ -1049,7 +1052,7 @@ sub Usage($$$) ...@@ -1049,7 +1052,7 @@ sub Usage($$$)
my $lastin = 0; my $lastin = 0;
while (my ($eid,$idx,$urn,$slice_uuid, 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()) { $query_result->fetchrow_array()) {
# In the emulab-ops project, we nalloc nodes to experiments that # In the emulab-ops project, we nalloc nodes to experiments that
# have never been swapped in (like hwdown). # have never been swapped in (like hwdown).
...@@ -1059,6 +1062,13 @@ sub Usage($$$) ...@@ -1059,6 +1062,13 @@ sub Usage($$$)
next next
if ($count == 0 || !defined($type)); 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. # The order by clause is important.
if ($swapin_time != $lastin) { if ($swapin_time != $lastin) {
unshift(@summary, {"eid" => $eid, unshift(@summary, {"eid" => $eid,
...@@ -1066,6 +1076,8 @@ sub Usage($$$) ...@@ -1066,6 +1076,8 @@ sub Usage($$$)
"slice_uuid" => $slice_uuid || "", "slice_uuid" => $slice_uuid || "",
"start" => $swapin_time, "start" => $swapin_time,
"end" => $swapout_time || "", "end" => $swapout_time || "",
"user_uid" => $swapper_uid,
"user_urn" => $swapper_urn,
"types" => {$type => {"count" => $count}}}); "types" => {$type => {"count" => $count}}});
$lastin = $swapin_time; $lastin = $swapin_time;
next; 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