Show: "; if ($showtype != "active") { echo "Active, "; } else { echo "Active, "; } if ($showtype != "batch") { echo "Batch, "; } else { echo "Batch, "; } if ($isadmin) { if ($showtype != "idle") { echo "Idle, "; } else { echo "Idle, "; } } if ($showtype != "all") { echo "All"; } else { echo "All"; } echo "
\n"; # Default value for showlastlogin is 1 for admins $showlastlogin = $isadmin; # Note: setting this to 1 for non-admins still does not make the column # show properly... it just shows the header in the table, over the # wrong column. # How many hours is considered idle... $idlehours = TBGetSiteVar("idle/threshold"); # # Handle showtype # if (! strcmp($showtype, "all")) { $title = "All"; } elseif (! strcmp($showtype, "active")) { # Active is now defined as "having nodes reserved" - we just depend on # the fact that we skip expts with no nodes further down... # But for speed, explicitly exclude expts that say they are "swapped" # (leave in activating, swapping, etc.) $clause = "e.state !='$TB_EXPTSTATE_SWAPPED'"; $title = "Active"; $having = "having (ncount>0)"; $active = 1; } elseif (! strcmp($showtype, "batch")) { $clause = "(e.batchmode=1 and e.state!='" . $TB_EXPTSTATE_SWAPPED . "')"; $title = "Batch"; } elseif ((!strcmp($showtype, "idle")) && $isadmin ) { # Do not put active in the clause for same reason as active # However, it takes a long time with so many swapped expts $clause = "e.state !='$TB_EXPTSTATE_SWAPPED'"; $title = "Idle"; #$having = "having (lastswap>=1)"; # At least one day since swapin $having = "having (lastswap>=0)"; $idle = 1; $showlastlogin = 0; # do not show a lastlogin column } else { # See active above $title = "Active"; $having = "having (ncount>0)"; $active = 1; } if (!$idle) { echo "View: "; if ($thumb != 0) { echo ""; echo "List"; echo ""; } else { echo "List"; } echo ", "; if ($thumb != 1) { echo ""; echo "Detailed Thumbnails"; echo ""; } else { echo "Detailed Thumbnails"; } echo ", "; if ($thumb != 2) { echo ""; echo "Brief Thumbnails"; echo ""; } else { echo "Brief Thumbnails"; } echo "
\n"; if ($thumb && !$idle) { echo "Sort by: "; if (isset($sortby) && $sortby != "normal" && $sortby != "pid") { echo ""; echo "Project"; echo ", "; } else { echo "Project, "; } if ($sortby != "eid") { echo ""; echo "Experiment ID"; echo ", "; } else { echo "Experiment ID, "; } if ($sortby != "pcs") { echo ""; echo "Node Usage"; echo ", "; } else { echo "Node Usage, "; } if ($sortby != "name") { echo ""; echo "Experiment Description"; echo ", "; } else { echo "Experiment Description, "; } if ($sortby != "uid") { echo ""; echo "Creator"; echo ""; } else { echo "Creator"; } echo "
\n"; } } echo "
\n"; # # Handle sortby. # if (! strcmp($sortby, "normal") || ! strcmp($sortby, "pid")) $order = "e.pid,e.eid"; elseif (! strcmp($sortby, "eid")) $order = "e.eid,e.expt_head_uid"; elseif (! strcmp($sortby, "uid")) $order = "e.expt_head_uid,e.pid,e.eid"; elseif (! strcmp($sortby, "name")) $order = "e.expt_name"; elseif (! strcmp($sortby, "pcs")) $order = "ncount DESC,e.pid,e.eid"; elseif (! strcmp($sortby, "idle")) $order = "canbeidle desc,idle_ignore,idlesec DESC,ncount desc,e.pid,e.eid"; else $order = "e.pid,e.eid"; # # Show a menu of all experiments for all projects that this uid # is a member of. Or, if an admin type person, show them all! # if ($clause) { $clause = "and ($clause)"; } else { $clause = ""; } # Notes about the queries below: # - idle is fudged by 121 seconds so that in the five minutes between # slothd reports we do not get active expts showing up as idle for 0.1 hrs if ($isadmin) { $experiments_result = DBQueryFatal(" select e.*, date_format(expt_swapped,'%Y-%m-%d') as d, date_format(expt_swapped,'%c/%e') as dshort, (to_days(now())-to_days(expt_swapped)) as lastswap, count(r.node_id) as ncount, swap_requests, round((unix_timestamp(now())-unix_timestamp(last_swap_req))/3600,1) as lastreq, (unix_timestamp(now()) - unix_timestamp(max(greatest( last_tty_act,last_net_act,last_cpu_act,last_ext_act)))) as idlesec, (max(last_report) is not null) as canbeidle, s.rsrcidx from experiments as e left join reserved as r on e.pid=r.pid and e.eid=r.eid left join experiment_stats as s on e.idx=s.exptidx left join nodes as n on r.node_id=n.node_id left join node_activity as na on r.node_id=na.node_id where (n.type!='dnard' or n.type is null) $clause group by e.pid,e.eid $having order by $order"); } else { $experiments_result = DBQueryFatal(" select distinct e.*, date_format(expt_swapped,'%Y-%m-%d') as d, date_format(expt_swapped,'%c/%e') as dshort, count(r.node_id) as ncount, (unix_timestamp(now()) - unix_timestamp(max(greatest( last_tty_act,last_net_act,last_cpu_act,last_ext_act)))) as idlesec, (max(last_report) is not null) as canbeidle, s.rsrcidx from group_membership as g left join experiments as e on g.pid=e.pid and g.pid=g.gid left join experiment_stats as s on e.idx=s.exptidx left join reserved as r on e.pid=r.pid and e.eid=r.eid left join nodes as n on r.node_id=n.node_id left join node_activity as na on r.node_id=na.node_id where (n.type!='dnard' or n.type is null) and g.uid='$uid' and e.pid is not null and e.eid is not null $clause group by e.pid,e.eid $having order by $order"); } if (! mysql_num_rows($experiments_result)) { USERERROR("There are no experiments running in any of the projects ". "you are a member of.", 1); } if (mysql_num_rows($experiments_result)) { echo "

$title Experiments

\n"; if ($idle) { echo "

Experiments that have been idle at least $idlehours hours
\n"; if ($noignore) { echo "\n Exclude idle-ignore experiments


\n"; } else { echo "\n Include idle-ignore experiments


\n"; } } $idlemark = "*"; $stalemark = "?"; $parens = 0; # # Okay, I decided to do this as one big query instead of a zillion # per-exp queries in the loop below. No real reason, except my personal # desire not to churn the DB. # $total_usage = array(); $perexp_usage = array(); # # Geta all the classes of nodes each experiment is using, and create # a two-D array with their counts. # $usage_query = DBQueryFatal("select r.pid,r.eid,nt.class, ". " count(nt.class) as ncount ". "from reserved as r ". "left join nodes as n on r.node_id=n.node_id ". "left join node_types as nt on n.type=nt.type ". "where n.type!='dnard' ". "group by r.pid,r.eid,nt.class"); while ($row = mysql_fetch_array($usage_query)) { $pid = $row[0]; $eid = $row[1]; $class = $row[2]; $count = $row[3]; $perexp_usage["$pid:$eid"][$class] = $count; } # # Now shove out the column headers. # if ($thumb && !$idle) { if ($thumb == 2) { echo ""; } else { echo "
"; } $thumbCount = 0; while ($row = mysql_fetch_array($experiments_result)) { $pid = $row["pid"]; $eid = $row["eid"]; $huid = $row["expt_head_uid"]; $name = stripslashes($row["expt_name"]); $date = $row["dshort"]; $rsrcidx = $row["rsrcidx"]; if ($idle && ($str==" " || !$pcs)) { continue; } if ($thumb == 2) { if ($pid != "emulab-ops") { echo ""; $thumbcount++; if (($thumbcount % 4) == 0) { echo "\n"; } } } else { echo ""; $thumbcount++; if (($thumbcount % 2) == 0) { echo "\n"; } } } echo "
". "". "". "
\n". "". "
$pid/
". "$eid". "
". "
". "". "". "". "\n"; } if ($lastlogin != "") { echo "Last Login: $lastlogin
\n"; } } echo "Created by: ". "$huid". "
\n"; $special = 0; $pcs = 0; reset($perexp_usage); if (isset($perexp_usage["$pid:$eid"])) { while (list ($class, $count) = each($perexp_usage["$pid:$eid"])) { if (strcmp($class, "pc")) { $special += $count; } else { $pcs += $count; } } } if ($pcs) { if ($pcs == 1) { $plural = ""; } else { $plural = "s"; } echo "Using $pcs PC Node$plural
\n"; } if ($special) { if ($special == 1) { $plural = ""; } else { $plural = "s"; } echo "Using $special Special Node$plural
\n"; } echo "
". "". "". "". "". "". "$pid/". "$eid". "". "
\n". "$name". "
\n"; if ($isadmin) { $swappable= $row["swappable"]; $swapreq=$row["swap_requests"]; $lastswapreq=$row["lastreq"]; $lastlogin = ""; if ($lastexpnodelogins = TBExpUidLastLogins($pid, $eid)) { $daysidle=$lastexpnodelogins["daysidle"]; #if ($idle && $daysidle < 1) # continue; $lastlogin .= $lastexpnodelogins["shortdate"] . " " . "(" . $lastexpnodelogins["uid"] . ")"; } elseif ($state=="active") { $daysidle=$row["lastswap"]; $lastlogin .= "$date swapin"; } # if ($lastlogin=="") { $lastlogin="
 
\n"; echo "
"; } else { $ni = ($noignore ? "&noignore=$noignore" : ""); echo "\n"; if ($showlastlogin) echo "\n"; if ($idle) { #echo "\n"; echo "\n"; } echo " \n"; while ($row = mysql_fetch_array($experiments_result)) { $pid = $row["pid"]; $eid = $row["eid"]; $huid = $row["expt_head_uid"]; $name = stripslashes($row["expt_name"]); $date = $row["dshort"]; $state= $row["state"]; $ignore = $row['idle_ignore']; $idlesec= $row["idlesec"]; $swapreqs = $row["swap_requests"]; $isidle = ($idlesec >= 3600*$idlehours); $stale = TBGetExptIdleStale($pid,$eid); $daysidle=0; $idletime = ($idlesec > 300 ? round($idlesec/3600,1) : 0); # reset pcs $pcs=0; if ($swapreqs && !$isidle) { $swapreqs = ""; mysql_query("update experiments set swap_requests='' ". "where pid='$pid' and eid='$eid'"); } if ($isadmin) { $swappable= $row["swappable"]; $swapreq=$row["swap_requests"]; $lastswapreq=$row["lastreq"]; if ($lastswapreq > $idletime) { # My last request was from _before_ it was idle this time mysql_query("update experiments set swap_requests='' ". "where pid='$pid' and eid='$eid'"); $swapreq=0; } $idlemailinterval = TBGetSiteVar("idle/mailinterval"); # Is it toosoon to send another mail? $toosoon = ($swapreq>0 && ($lastswapreq < $idlemailinterval)); $lastlogin = "\n"; if ($lastlogin=="\n") { $lastlogin="\n"; } } if ($idle) { # If it is ignored, skip it now. if ($ignore && !$noignore) { continue; } #$lastlogin .= "\n"; if (isset($perexp_usage["$pid:$eid"]) && isset($perexp_usage["$pid:$eid"]["pc"])) { $pcs = $perexp_usage["$pid:$eid"]["pc"]; } $foo = "\n" ; #} else { # if ($label == "") { $label = " "; } # $fooswap = ""; # if (!$pcs) { $foo .= "(no PCs)\n"; } # else { $foo .=" "; } #} if ($swapreq > 0) { $foo .= "$swapreq sent
". "(${lastswapreq} hrs ago)\n"; } #$foo .= "".$fooswap."\n"; if (!$swappable) { $foo .= "unswap.\n"; } } if ($idle && (!$pcs || !$isidle)) { continue; } $nodes = 0; $special = 0; reset($perexp_usage); if (isset($perexp_usage["$pid:$eid"])) { while (list ($class, $count) = each($perexp_usage["$pid:$eid"])) { $nodes += $count; if (strcmp($class, "pc")) { $special = 1; } else { $pcs = $count; } # Summary counts for just the experiments in the projects # the user is a member of. if (!isset($total_usage[$class])) $total_usage[$class] = 0; $total_usage[$class] += $count; } } # in idle or active, skip experiments with no nodes. if (($idle || $active) && $nodes == 0) { continue; } if ($nodes==0) { $nodes = " "; } echo "\n"; if ($isidle && !$ignore) { $nodes = $nodes.$idlemark; } # If multiple classes, then hightlight the number and show pcs/nodes. if ($special) { if ($pcs) echo "\n"; else echo "\n"; } else echo "\n"; if ($idletime == -1) { $idlestr = " "; } else { $idlestr = "$idletime"; # Order between the next two lines determines if the # stalemark goes inside or outside the parens if ($stale && $pcs > 0) { $idlestr .= $stalemark; } if ($ignore && $idletime !=0) { $idlestr = "($idlestr)"; $parens = 1; } } echo ""; if ($showlastlogin) echo "$lastlogin\n"; if ($idle) echo "$foo\n"; echo "\n"; } echo "
PID EID PCs [1] Hours Idle [2]Last LoginSwap RequestsSwap Requests Description Head UID
"; if ($lastexpnodelogins = TBExpUidLastLogins($pid, $eid)) { $daysidle=$lastexpnodelogins["daysidle"]; #if ($idle && $daysidle < 1) # continue; $lastlogin .= $lastexpnodelogins["shortdate"] . " " . "(" . $lastexpnodelogins["uid"] . ")"; } elseif ($state=="active") { $daysidle=$row["lastswap"]; $lastlogin .= "$date swapin"; } $lastlogin.=" $daysidle\n"; #$label = ""; # Probably do not need this when we are using stalemark #if ($stale) { $label .= "stale "; } # Do not really need this if we are marking ignore with () #if ($ignore) { $label .= "ignore "; } #if (!$swappable) { $label .= "unswap. "; } #if ($isidle && !$stale && !$ignore && !$toosoon && $pcs) { # $fooswap = "". # " $label$label
$pid $eid$nodes ($pcs)$nodes$nodes$idlestr$name $huid
\n"; echo "
  1. Red indicates nodes other than PCs. A $idlemark mark by the node count indicates that the experiment is currently considered idle. The number of local pcs is indicated in the parens.
  2. A $stalemark indicates that the data is stale, and at least one node in the experiment has not reported on its proper schedule.\n"; if ($parens) { # don't show this unless we did it... most users shouldn't ever # need to know that you can set expts to have their idleness ignored echo "Values are in parenthesis for idle-ignore experiments.\n"; } echo "
\n"; echo "
Node Totals
\n"; echo "\n"; $total = 0; ksort($total_usage); while (list($type, $count) = each($total_usage)) { $total += $count; echo "\n"; } echo "\n"; echo "\n"; echo "
${type}:         $count

       
Total:         $total
\n"; } # if ($thumb && !$idle) } # if (mysql_num_rows($experiments_result)) # # Standard Testbed Footer # PAGEFOOTER(); ?>