Commit 37cbb3e8 authored by Mac Newbold's avatar Mac Newbold
Browse files

Add swap request tracking. Two new columns in expt table (swap_requests

and last_swap_req) track the count and last time a request was sent.

The counters all get reset by idlecheck every time it runs unless it
detects you as inactive. Then when you go to send a swap request, it
will show you the info about how many have been sent and when the last
one was, and will let you know if the swap request will also go to the
proj leader if you send it. When you send the request, the email
mentions how many reminders you've been sent already, and only gets
cc'd to proj head on the third message (or more). Then it updates the
count and the timestamp of the last request sent.
parent f56accba
......@@ -156,6 +156,7 @@ while(@r=$result->fetchrow()) {
print $result->as_string() if ($d>1);
my @list=();
# Find expts that have nodes reserved, and look up their bits.
$cmd = "select,r.eid,swappable,expt_swapped from reserved as r
left join experiments as e on and e.eid=r.eid
......@@ -181,7 +182,15 @@ while(@r=$result->fetchrow()) {
if (($idle && !$stale && $swap) ||
($stale && $s) ||
(!$swap && $u)) { print $str; }
if ($idle) { push(@list,"(pid='$pid' and eid='$eid')"); }
print $result->as_string() if ($d>1);
if (@list > 0) {
$cmd = "update experiments set swap_requests=0 where not (".
join(" or ",@list).")";
print "Sending cmd:\n$cmd\n" if $d;
......@@ -182,6 +182,8 @@ CREATE TABLE experiments (
wa_delay_solverweight float default '0',
wa_bw_solverweight float default '0',
wa_plr_solverweight float default '0',
swap_requests tinyint(4) NOT NULL default '0',
last_swap_req datetime default NULL,
PRIMARY KEY (eid,pid)
......@@ -56,8 +56,27 @@ if ($canceled) {
# We only send to the proj leader after we've sent $tell_proj_head requests
$tell_proj_head = 2;
$q = DBQueryWarn("select swap_requests,
date_format(last_swap_req,\"%T\") as lastreq
from experiments
where eid='$eid' and pid='$pid'");
$r = mysql_fetch_array($q);
$swap_requests = $r["swap_requests"];
$last_swap_req = $r["lastreq"];
if (!$confirmed) {
echo "<center><h2><br>
Experiment '$eid' in project '$pid' has been sent
$swap_requests swap request(s) since it went idle.\n";
if ($swap_requests > 0) {
echo "The most recent one was sent at $last_swap_req.\n";
if ($swap_requests >= $tell_proj_head) {
echo "This notification will also be sent to the project leader.\n";
echo "<p>
Are you sure you want to send an email message requesting that<br>
experiment '$eid' be swapped or terminated?
......@@ -101,6 +120,10 @@ $c=$r["c"];
TBMAIL("$expleader_name <$expleader_email>",
"$pid/$eid: Please Swap or Terminate Experiment",
"Hi, this is an automated message from Emulab.Net.\n".
( $swap_requests > 0
? ("You have been sent ".($swap_requests+1)." messages since this ".
"experiment became idle.\n")
: "") .
"It appears that the $c nodes in your experiment '$eid' \n".
"in project '$pid' are inactive.\n".
......@@ -120,7 +143,9 @@ TBMAIL("$expleader_name <$expleader_email>",
"Utah Network Testbed\n",
"From: $TBMAIL_OPS\n".
"Cc: $projleader_name <$projleader_email>\n".
( $swap_requests >= $tell_proj_head
? "Cc: $projleader_name <$projleader_email>\n"
: "") .
"Bcc: $TBMAIL_OPS\n".
"Errors-To: $TBMAIL_WWW");
......@@ -135,6 +160,10 @@ TBMAIL($TBMAIL_AUDIT,
"From: $uid_name <$uid_email>\n".
"Errors-To: $TBMAIL_WWW");
# Update the count and the time in the database
DBQueryWarn("update experiments set swap_requests= swap_requests+1,
last_swap_req=now() where pid='$pid' and eid='$eid';");
echo "<p><center>
Message successfully sent!
Supports Markdown
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