showexp_list.php3 19.3 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7 8 9 10 11
include("defs.php3");

#
# Standard Testbed Header
#
12
PAGEHEADER("Experiment Information Listing");
13 14 15 16 17 18 19

#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

20
$isadmin     = ISADMIN($uid);
21 22
$clause      = 0;
$having      = "";
Mac Newbold's avatar
Mac Newbold committed
23 24
$active      = 0;
$idle        = 0;
25

Leigh B. Stoller's avatar
Leigh B. Stoller committed
26 27
if (! isset($showtype))
    $showtype="active";
28 29
if (! isset($sortby))
    $sortby = "normal";
30 31
if (! isset($thumb)) 
    $thumb = 0;
32

33
echo "<b>Show: ";
34

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
if ($showtype != "active") {
    echo "<a class='static' href='showexp_list.php3?showtype=active&sortby=$sortby&thumb=$thumb'>Active</a>, ";
} else {
    echo "Active, ";
}

if ($showtype != "batch") {
    echo "<a class='static' href='showexp_list.php3?showtype=batch&sortby=$sortby&thumb=$thumb'>Batch</a>, ";
} else {
    echo "Batch, ";
}

if ($isadmin) {
    if ($showtype != "idle") {
	echo "<a class='static' href='showexp_list.php3?showtype=idle&sortby=$sortby&thumb=$thumb'>Idle</a>, ";
    } else {
	echo "Idle, ";
    }
}

if ($showtype != "all") {
    echo "<a class='static' href='showexp_list.php3?showtype=all&sortby=$sortby&thumb=$thumb'>All</a>";
} else {
    echo "All";
}

echo "</b><br />\n";

#echo "<b>Show:
#         <a class='static' href='showexp_list.php3?showtype=active&sortby=$sortby&thumb=$thumb'>active</a>,
#         <a class='static' href='showexp_list.php3?showtype=batch&sortby=$sortby&thumb=$thumb'>batch</a>,";
#if ($isadmin) 
#     echo "\n<a class='static' href='showexp_list.php3?showtype=idle&sortby=$sortby&thumb=$thumb'".
#       ">idle</a>,";
#
#echo "\n       <a class='static' href='showexp_list.php3?showtype=all&sortby=$sortby&thumb=$thumb'>all</a>.
#      </b><br />\n";
72

73 74 75 76 77
# Default value for showlastlogin is 1 for admins
$showlastlogin = $isadmin;
# Note: setting this to 1 for non-admins still doesn't make the column
# show properly... it just shows the header in the table, over the
# wrong column. 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
78

79 80 81
# how many hours is considered idle...
$idlehours = 2;

Leigh B. Stoller's avatar
Leigh B. Stoller committed
82 83 84 85 86 87 88
#
# Handle showtype
# 
if (! strcmp($showtype, "all")) {
    $title  = "All";
}
elseif (! strcmp($showtype, "active")) {
89 90
    # Active is now defined as "having nodes reserved" - we just depend on
    # the fact that we skip expts with no nodes further down...
91 92 93
    # But for speed, explicitly exclude expts that say they are "swapped"
    # (leave in activating, swapping, etc.)
    $clause = "e.state !='$TB_EXPTSTATE_SWAPPED'";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
94
    $title  = "Active";
95
    $having = "having (ncount>0)";
96
    $active = 1;
Leigh B. Stoller's avatar
Leigh B. Stoller committed
97 98 99 100
}
elseif (! strcmp($showtype, "batch")) {
    $clause = "e.batchmode=1";
    $title  = "Batch";
101
}
102
elseif ((!strcmp($showtype, "idle")) && $isadmin ) {
103
    # Do not put active in the clause for same reason as active
104 105
    # However, it takes a long time with so many swapped expts
    $clause = "e.state !='$TB_EXPTSTATE_SWAPPED'";
106
    $title  = "Idle";
107 108
    #$having = "having (lastswap>=1)"; # At least one day since swapin
    $having = "having (lastswap>=0)";
109
    $idle = 1;
110
    $showlastlogin = 0; # don't show a lastlogin column
111
}
112
else {
113
    # See active above
Leigh B. Stoller's avatar
Leigh B. Stoller committed
114
    $title  = "Active";
115
    $having = "having (ncount>0)";
116
    $active = 1;
117
}
118

119 120 121


if (!$idle) {
122 123 124
    echo "<b>View: ";

    if ($thumb != 0) {
125
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=$sortby&thumb=0'>";
126 127 128 129 130 131 132 133
	echo "List";
        echo "</a>";
    } else {
        echo "List";
    }
    echo ", ";

    if ($thumb != 1) {
134
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=$sortby&thumb=1'>";
135 136
	echo "Detailed Thumbnails";
        echo "</a>";
137
    } else {
138
        echo "Detailed Thumbnails";
139
    }
140 141 142
    echo ", ";

    if ($thumb != 2) {
143
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=$sortby&thumb=2'>";
144 145 146 147 148 149
	echo "Brief Thumbnails";
        echo "</a>";
    } else {
        echo "Brief Thumbnails";
    }
    echo "</b><br />\n";
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190

if ($thumb && !$idle) {
    echo "<b>Sort by: ";
    if (isset($sortby) && $sortby != "normal" && $sortby != "pid") {
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=pid&thumb=$thumb'>";
	echo "Project";
        echo "</a>, ";
    } else {
        echo "Project, ";
    }	
    if ($sortby != "eid") {
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=eid&thumb=$thumb'>";
	echo "Experiment ID";
        echo "</a>, ";
    } else {
        echo "Experiment ID, ";
    }
    if ($sortby != "pcs") {
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=pcs&thumb=$thumb'>";
	echo "Node Usage";
        echo "</a>, ";
    } else {
        echo "Node Usage, ";
    }	
    if ($sortby != "name") {
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=name&thumb=$thumb'>";
	echo "Experiment Description";
        echo "</a>, ";
    } else {
        echo "Experiment Description, ";
    }	
    if ($sortby != "uid") {
	echo "<a class='static' href='showexp_list.php3?showtype=$showtype&sortby=uid&thumb=$thumb'>";
	echo "Creator";
        echo "</a>";
    } else {
        echo "Creator";
    }

    echo "</b><br />\n";
}
191 192
 
#    if (!$thumb) {
193
#	echo "<b><a class='static' href='showexp_list.php3?showtype=$showtype&sortby=$sortby&thumb=1'>".
194 195 196
#             "Switch to Thumbnail view".
#	     "</a></b><br />";
#    } else {
197
#	echo "<b><a class='static' href='showexp_list.php3?showtype=$showtype&sortby=$sortby&thumb=0'>".
198 199 200
#             "Switch to List view".
#	     "</a></b><br />";
#    }
201 202 203 204
}

echo "<br />\n";

Leigh B. Stoller's avatar
Leigh B. Stoller committed
205 206 207
#
# Handle sortby.
# 
208 209 210 211 212 213 214 215 216
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";
217
elseif (! strcmp($sortby, "pcs"))
218
    $order = "ncount DESC,e.pid,e.eid";
219 220 221
else 
    $order = "e.pid,e.eid";

222 223 224 225
#
# 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!
#
226 227 228 229 230 231
if ($clause) {
    $clause = "and ($clause)";
} else {
    $clause = "";
}
    
232
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
233
    $experiments_result =
234
	DBQueryFatal("select e.*,".
235
		     "date_format(expt_swapped,\"%Y-%m-%d\") as d, ".
236
                     "date_format(expt_swapped,'%c/%e') as dshort, ".
237
		     "(to_days(now())-to_days(expt_swapped)) as lastswap, ".
238
                     "count(r.node_id) as ncount, swap_requests, ".
239
		     "round((unix_timestamp(now()) - ".
240 241
		     "unix_timestamp(last_swap_req))/3600,1) as lastreq, ".
		     "ve.thumb_hash as thumb_hash ".
242
		     "from experiments as e ".
243 244
		     "left join vis_experiments as ve on ".
		     "ve.pid=e.pid and ve.eid=e.eid ".
245 246 247 248 249
                     "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 ".
                     "where (n.type!='dnard' or n.type is null) $clause ".
                     "group by e.pid,e.eid ".
		     "$having ".
250
		     "order by $order");
251 252
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
253
    $experiments_result =
254 255
	DBQueryFatal("select distinct e.*, ".
                     "date_format(expt_swapped,'%Y-%m-%d') as d, ".
256
                     "date_format(expt_swapped,'%c/%e') as dshort, ".
257 258
                     "count(r.node_id) as ncount, ".
		     "ve.thumb_hash as thumb_hash ".
259 260 261
                     "from group_membership as g ".
                     "left join experiments as e on ".
                     "  g.pid=e.pid and g.pid=g.gid ".
262 263
		     "left join vis_experiments as ve on ".
		     "ve.pid=e.pid and ve.eid=e.eid ".
264 265 266
                     "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 ".
                     "where (n.type!='dnard' or n.type is null) and ".
267 268
                     " g.uid='$uid' and e.pid is not null ".
		     "and e.eid is not null $clause ".
269 270
                     "group by e.pid,e.eid ".
		     "$having ".
271
                     "order by $order");    
272
}
273
if (! mysql_num_rows($experiments_result)) {
274 275
    USERERROR("There are no experiments running in any of the projects ".
              "you are a member of.", 1);
276 277
}

278 279
if (mysql_num_rows($experiments_result)) {
    echo "<center>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
280
           <h2>$title Experiments</h2>
281
          </center>\n";
282

Mac Newbold's avatar
Mac Newbold committed
283
    if ($idle) {
284
      echo "<p><center><b>Experiments that have been idle at least $idlehours hours</b></center></p><br />\n";
Mac Newbold's avatar
Mac Newbold committed
285
    }
286
    
287
    $idlemark = "<b>*</b>";
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
    #
    # 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;
    }
317 318 319 320

    #
    # Now shove out the column headers.
    #
321
if ($thumb && !$idle) {
322 323 324 325 326
    if ($thumb == 2) {
	echo "<table border=2 cols=4 cellpadding=2 cellspacing=2 align=center><tr>";
    } else {
	echo "<table border=2 cols=2 cellpadding=2 cellspacing=2 align=center><tr>";
    }
327 328 329 330 331 332 333
    $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"]);
334
	$date = $row["dshort"];
335
	$thumb_hash = $row["thumb_hash"];
336 337
	
	if ($idle && ($str=="&nbsp;" || !$pcs)) { continue; }
338 339 340 341 342 343 344 345 346 347 348 349 350

	if ($TBMAINSITE) {
	    # if image is not in thumbs dir, render it!
	    if ($thumb_hash && !file_exists ($TBDIR . "www/thumbs/tn$thumb_hash.png")) {
		# we'll be paranoid, and escape pid and eid.
		$prerender_cmd = $TBDIR . "libexec/vis/prerender -t " . 
		                 escapeshellcmd($pid) . " " . escapeshellcmd($eid) .
				 " > /dev/null";
		#echo "<!-- rerendered $pid $eid -->";
		system( $prerender_cmd );
	    }
	}

351 352 353 354 355
#	echo "<table style=\"float: none;\" width=256 height=192><tr><td>".
#	echo "And<table align=left width=256 height=192><tr width=256><td height=192>".
#	echo "<table width=256 height=192><tr><td>".
#	echo "<td width=50%>".
#	echo "<tr
356

357 358 359 360 361 362 363 364 365 366 367 368
	if ($thumb == 2) {
	    if ($pid != "emulab-ops") {
		echo "<td align=center>".
		     "<a href='shownsfile.php3?pid=$pid&eid=$eid'>".
		     "<img border=1 width=128 height=128 class='stealth' ".
		     " src='thumbs/tn$thumb_hash.png' />".
		     "<br />\n".
		     "<b>".
		     "<a href='showproject.php3?pid=$pid'>$pid</a>/<br />".
		     "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>".
		     "</b>".
		     "</td>";
Chad Barb's avatar
Chad Barb committed
369 370 371

		$thumbcount++;
		if (($thumbcount % 4) == 0) { echo "</tr><tr>\n"; }
372 373 374 375 376 377 378 379 380
	    }
	} else {

	    echo "<td>".
		 "<table border=0 cellpadding=4 cellspacing=0>".
		 "<tr>".
		 "<td width=128 align=center>".
	         "<a href='shownsfile.php3?pid=$pid&eid=$eid'>".
		 "<img border=1 width=128 height=128 class='stealth' ".
381 382
#	     " src='top2image.php3?pid=$pid&eid=$eid&thumb=128' />".
#	     " src='thumbs/$pid.$eid.png' />".
383 384 385 386 387 388 389 390 391 392 393
		 " src='thumbs/tn$thumb_hash.png' />".
	         "</a>".
                 "</td>".
	         "<td align=left class='paddedcell'>".
	         "<b>".
 	         "<a href='showproject.php3?pid=$pid'>$pid</a>/".
                 "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>".
	         "</b>".
	         "<br />\n".
	         "<b><font size=-1>$name</font></b>".
                 "<br />\n";
394 395


396 397 398 399 400 401 402 403 404
	    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;
405
		    $lastlogin .= $lastexpnodelogins["shortdate"] . " " .
406 407 408
			"(" . $lastexpnodelogins["uid"] . ")";
		} elseif ($state=="active") {
		    $daysidle=$row["lastswap"];
409
		    $lastlogin .= "$date swapin";
410 411 412 413 414 415
		}
		# if ($lastlogin=="") { $lastlogin="<td>&nbsp;</td>\n"; }
		if ($lastlogin != "") {
		    echo "<font size=-2><b>Last Login:</b> $lastlogin</font><br />\n";
		}
	    }	
416

417 418 419
	    echo "<font size=-2><b>Created by:</b> ".
		 "<a href='showuser.php3?target_uid=$huid'>$huid</a>".
		 "</font><br />\n";
420

421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
	    $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 "<font size=-1><b>Using <font color=red>$pcs PC</font> Node$plural</b></font><br />\n";
	    }
	    if ($special) {
		if ($special == 1) { $plural = ""; } else { $plural = "s"; }  
		echo "<font size=-1><b>Using <font color=red>$special Special</font> Node$plural</b></font><br />\n";
	    }

443 444
	    echo "</td></tr></table> \n";
	    echo "</td>";
445

Chad Barb's avatar
Chad Barb committed
446
	    $thumbcount++;
447 448
	    if (($thumbcount % 2) == 0) { echo "</tr><tr>\n"; }
	}
449 450 451 452
    }

    echo "</tr></table>";
} else {
453 454 455
    echo "<table border=2 cols=0
                 cellpadding=0 cellspacing=2 align=center>
            <tr>
Chad Barb's avatar
Chad Barb committed
456
              <th width=8%>
457
               <a class='static' href='showexp_list.php3?showtype=$showtype&sortby=pid'>
458
                  PID</a></th>
Chad Barb's avatar
Chad Barb committed
459
              <th width=8%>
460
               <a class='static' href='showexp_list.php3?showtype=$showtype&sortby=eid'>
461
                  EID</a></th>
Chad Barb's avatar
Chad Barb committed
462
              <th align=center width=3%>
463
               <a class='static' href='showexp_list.php3?showtype=$showtype&sortby=pcs'>
464 465 466
                  PCs</a><br>[<b>1</b>]</th>
              <th align=center width=3%>
               Hours Idle</th>\n";
467
    
468
    if ($showlastlogin)
Chad Barb's avatar
Chad Barb committed
469
        echo "<th width=17% align=center>Last Login</th>\n";
470
    if ($idle) {
Chad Barb's avatar
Chad Barb committed
471
        #      "<th width=4% align=center>Days Idle</th>\n";
472 473
	echo "<th width=4% align=center colspan=2>Swap Request</th>\n";
    }
474

Chad Barb's avatar
Chad Barb committed
475
    echo "    <th width=60%>
476
               <a class='static' href='showexp_list.php3?showtype=$showtype&sortby=name'>
477
                  Name</a></th>
Chad Barb's avatar
Chad Barb committed
478
              <th width=4%>
479
               <a class='static' href='showexp_list.php3?showtype=$showtype&sortby=uid'>
480
                  Head UID</a></th>
481 482
            </tr>\n";

483
    while ($row = mysql_fetch_array($experiments_result)) {
484 485 486
	$pid  = $row["pid"];
	$eid  = $row["eid"]; 
	$huid = $row["expt_head_uid"];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
487
	$name = stripslashes($row["expt_name"]);
488
	$date = $row["dshort"];
489
	$state= $row["state"];
490
	$isidle = $row["swap_requests"];
491
	$daysidle=0;
492 493
	$idletime = round(TBGetExptIdleTime($pid,$eid),1);

494 495 496 497 498 499 500 501
	$inactive = $idletime >= $idlehours;
	if ($isidle && !$inactive) {
	    $isidle = "";
	    mysql_query("update experiments set swap_requests='' ".
			"where pid='$pid' and eid='$eid'");
	}

	
502
	if ($isadmin) {
503 504 505 506
	    $swappable= $row["swappable"];
	    $swapreq=$row["swap_requests"];
	    $lastswapreq=$row["lastreq"];
	    $lastlogin = "<td>";
507
	    if ($lastexpnodelogins = TBExpUidLastLogins($pid, $eid)) {
508
	        $daysidle=$lastexpnodelogins["daysidle"];
509 510
	        #if ($idle && $daysidle < 1)
		#  continue;
511
		$lastlogin .= $lastexpnodelogins["shortdate"] . " " .
512
		 "(" . $lastexpnodelogins["uid"] . ")";
513
	    } elseif ($state=="active") {
514
	        $daysidle=$row["lastswap"];
515
	        $lastlogin .= "$date swapin";
516
	    }
517 518
	    $lastlogin.="</td>\n";
	    if ($lastlogin=="<td></td>\n") { $lastlogin="<td>&nbsp;</td>\n"; }
519 520
	}

521
	if ($idle) {
522 523
	    $stale = TBGetExptIdleStale($pid,$eid);
	    $ignore = TBGetExptIdleIgnore($pid,$eid);
524 525
	    # If it is ignored, skip it now.
	    if ($ignore) { continue; }
526
	    #$lastlogin .= "<td align=center>$daysidle</td>\n";
527 528 529 530
	    if (isset($perexp_usage["$pid:$eid"]) &&
		isset($perexp_usage["$pid:$eid"]["pc"])) {
	      $pcs = $perexp_usage["$pid:$eid"]["pc"];
	    } else { $pcs=0; }
531
	    $foo = "<td align=center valign=center>\n";
532
 	    if ($inactive && !$stale && !$ignore && $pcs && $swappable) {
533 534 535
		$fooswap = "<td><a ".
		    "href=\"request_swapexp.php3?pid=$pid&eid=$eid\">".
		    "<img border=0 src=\"redball.gif\"></a></td>\n" ;
536
	    } else {
537 538 539
		$label = "";
		if ($stale) { $label .= "stale "; }
		if ($ignore) { $label .= "ignore "; }
540
		if (!$swappable) { $label .= "unswap. "; }
541 542 543 544
		if ($label == "") { $label = "&nbsp;"; }
		$fooswap = "<td>$label</td>";
		if (!$pcs) { $foo .= "(no PCs)\n"; }
		else { $foo .="&nbsp;"; }
545 546
	    }
	    if ($swapreq > 0) {
547
	      $foo .= "&nbsp;$swapreq&nbsp;sent<br />".
548
	              "<font size=-2>(${lastswapreq}&nbsp;hrs&nbsp;ago)</font>\n";
549
	    }
550
	    $foo .= "</td>" . $fooswap . "\n"; 
551
	}
552

553
	if ($idle && ($str=="&nbsp;" || !$pcs || !$inactive)) { continue; }
554

555 556
	$nodes   = 0;
	$special = 0;
557 558 559 560
	reset($perexp_usage);
	if (isset($perexp_usage["$pid:$eid"])) {
	    while (list ($class, $count) = each($perexp_usage["$pid:$eid"])) {
		$nodes += $count;
561
		if (strcmp($class, "pc")) {
562
		    $special = 1;
563 564 565 566
		} else {
		    $pcs = $count;
		}

567 568 569 570 571 572 573

		# 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;
574
	    }
575
	}
576 577 578

	# in idle or active, skip experiments with no nodes.
	if (($idle || $active) && $nodes == 0) { continue; }
579 580
	if ($nodes==0) { $nodes = "&nbsp;"; }
	
581 582
	echo "<tr>
                <td><A href='showproject.php3?pid=$pid'>$pid</A></td>
Leigh B. Stoller's avatar
Leigh B. Stoller committed
583
                <td><A href='showexp.php3?pid=$pid&eid=$eid'>
584
                       $eid</A></td>\n";
585 586
	
	if ($isidle) { $nodes = $nodes.$idlemark; }
587 588 589 590 591
	# If multiple classes, then hightlight the number.
	if ($special)
            echo "<td><font color=red>$nodes</font></td>\n";
	else
            echo "<td>$nodes</td>\n";
592

Chad Barb's avatar
Chad Barb committed
593 594 595 596 597
	if ($idletime == -1) {
	    echo "<td>&nbsp;</td>\n";
	} else {
	    echo "<td>$idletime</td>\n";
	}
598 599
	
	if ($showlastlogin) echo "$lastlogin\n";
600
	if ($idle) echo "$foo\n";
601 602

        echo "<td>$name</td>
603 604
                <td><A href='showuser.php3?target_uid=$huid'>
                       $huid</A></td>
605 606 607
               </tr>\n";
    }
    echo "</table>\n";
608 609 610

    echo "<ol>
             <li><font color=red>Red</font> indicates nodes other than PCs.
611 612
                 A $idlemark mark by the node count indicates that the
                 experiment is currently considered idle.
613 614 615
          </ol>\n";
    
    echo "<center><b>Node Totals</b></center>\n";
616 617 618
    echo "<table border=0
                 cellpadding=1 cellspacing=1 align=center>\n";
    $total = 0;
619
    ksort($total_usage);
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639
    while (list($type, $count) = each($total_usage)) {
	    $total += $count;
	    echo "<tr>
                    <td align=right>${type}:</td>
                    <td>&nbsp &nbsp &nbsp &nbsp</td>
                    <td align=center>$count</td>
                  </tr>\n";
    }
    echo "<tr>
             <td align=right><hr></td>
             <td>&nbsp &nbsp &nbsp &nbsp</td>
             <td align=center><hr></td>
          </tr>\n";
    echo "<tr>
             <td align=right><b>Total</b>:</td>
             <td>&nbsp &nbsp &nbsp &nbsp</td>
             <td align=center>$total</td>
          </tr>\n";
    
    echo "</table>\n";
640 641
} # if ($thumb && !$idle)
} # if (mysql_num_rows($experiments_result))
642 643 644 645 646 647

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>