explist.php3 4.09 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28
#
include("defs.php3");

#
# We let anyone access this page. No details are leaked out, hopefully.
#
29 30 31
$optargs = OptionalPageArguments("keymaster", PAGEARG_STRING);

# Locals
32
$thumbCount = 0;
33
$thumbMax   = 0;
34 35 36

function GENPLIST ($which, $query_result)
{
37
    global $thumbCount, $thumbMax, $TBOPSPID, $TB_EXPTSTATE_ACTIVE;
38 39 40 41 42

    echo "<center><h3>$which</h3></center>\n";
    echo "<table border=2 cols=4 cellpadding=2
                 cellspacing=2 align=center><tr>";

43 44
    while (($row = mysql_fetch_array($query_result)) &&
	   ($thumbMax == 0 || $thumbCount < $thumbMax)) {
45 46 47 48
	$pid        = $row["pid"];
	$eid        = $row["eid"];
	$pnodes     = $row["pnodes"];
	$swapdate   = $row["swapdate"];
49
	$state      = $row["state"];
50
	$rsrcidx    = $row["rsrcidx"];
51

52
	if ($pid == $TBOPSPID || $pnodes == 0) {
53 54
	    continue;
	}
55 56 57 58
	if ($state == $TB_EXPTSTATE_ACTIVE) {
	    $swapdate = "";
	}
	else {
59
	    $swapdate = "<font size=-1><br>$swapdate</font>";
60
	}
61 62

	echo "<td align=center>";
63
	echo "<img border=1 class='stealth' ".
64
	    " src='showthumb.php3?idx=$rsrcidx'>".
65
	    " $swapdate" .
66 67
	    "</td>";

68 69
	$thumbCount++;
	if (($thumbCount % 4) == 0) {
70 71 72 73 74 75
	    echo "</tr><tr>\n";
	}
    }
    echo "</tr></table>";
}

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
#
# Standard Testbed Header
#
if (isset($keymaster) &&
    strcmp($keymaster, "Clortho") == 0) {
    PAGEHEADER("All Experiments");

    $query_result =
	DBQueryFatal("select s.pid,s.eid,'terminated',s.rsrcidx,rs.pnodes, ".
		     "       s.swapin_last as swapdate ".
		     " from experiment_stats as s ".
		     "left join experiment_resources as rs on ".
		     "     rs.idx=s.rsrcidx ".
		     "where rs.pnodes>0 and rs.thumbnail is not null and ".
		     "      s.pid!='emulab-ops' ".
		     "order by s.swapin_last desc ");

    if (mysql_num_rows($query_result)) {
	GENPLIST("Experiments Run on Emulab", $query_result);
    }

    PAGEFOOTER();
    return;
}
else {
101
    PAGEHEADER("Active and Recently Swapped-out Experiments");
102 103
}

104 105 106 107
#
# Active Experiments.
# 
$query_result =
108
    DBQueryFatal("select e.pid,e.eid,e.state,s.rsrcidx,rs.pnodes, ".
109 110 111 112
		 "       s.swapin_last as swapdate ".
		 " from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
		 "left join experiment_resources as rs on rs.idx=s.rsrcidx ".
113
		 "where rs.pnodes>0 and rs.thumbnail is not null and ".
114 115
		 "      e.state='" . $TB_EXPTSTATE_ACTIVE . "' and " .
		 "      e.pid!='emulab-ops' and ".
116
		 "      not (e.pid='ron' and e.eid='all') ".
117 118
		 "order by s.swapin_last desc ");

119
echo "<a NAME=active></a>\n";
120 121 122 123 124
if (mysql_num_rows($query_result)) {
    GENPLIST("Active Experiments", $query_result);
}

$query_result =
125
    DBQueryFatal("select e.pid,e.eid,e.state,s.rsrcidx,rs.pnodes, ".
126 127 128 129
		 "       s.swapout_last as swapdate ".
		 " from experiments as e ".
		 "left join experiment_stats as s on s.exptidx=e.idx ".
		 "left join experiment_resources as rs on rs.idx=s.rsrcidx ".
130 131
		 "where (cast(rs.pnodes as signed) - ".
                 "       cast(rs.delaynodes as signed)) > 2 and ".
132
		 "      rs.thumbnail is not null and ".
133 134
		 "      e.state='" . $TB_EXPTSTATE_SWAPPED . "' " .
		 "order by s.swapout_last desc ".
135
		 "limit 200");
136

137
echo "<a NAME=swapped></a>\n";
138
if (mysql_num_rows($query_result)) {
139 140
    $thumbCount = 0;
    $thumbMax   = 80;
141
    GENPLIST("Recently Swapped-out Experiments", $query_result);
142 143 144 145 146 147 148
}

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