linkmon_list.php3 6.24 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2005, 2006, 2007 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");

#
# Only known and logged in users.
#
29 30 31
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
32 33

#
34
# Verify page arguments.
35
#
36 37 38 39 40 41 42 43 44 45 46
$reqargs = RequiredPageArguments("experiment", PAGEARG_EXPERIMENT);
$optargs = OptionalPageArguments("linklan",    PAGEARG_STRING,
				 "vnode",      PAGEARG_STRING,
				 "action",     PAGEARG_STRING);

# Need these below.
$pid = $experiment->pid();
$eid = $experiment->eid();

if (!$experiment->AccessCheck($this_user, $TB_EXPT_MODIFY)) {
    USERERROR("You do not have permission to run linktest on $pid/$eid!", 1);
47 48 49 50 51 52 53
}

#
# Must be active. The backend can deal with changing the base experiment
# when the experiment is swapped out, but we need to generate a form based
# on virt_lans instead of delays/linkdelays. Thats harder to do. 
#
54
if ($experiment->state() != $TB_EXPTSTATE_ACTIVE) {
55 56 57 58 59 60 61 62 63 64 65 66
    USERERROR("Experiment $eid must be active to monitor its links!", 1);
}

$query_result =
    DBQueryFatal("select * from traces ".
		 "where eid='$eid' AND pid='$pid' ".
		 "order by linkvname,vnode");

if (mysql_num_rows($query_result) == 0) {
    USERERROR("No links are being traced/monitored in $eid/$pid!", 1);
}

67 68 69 70 71
#
# Standard Testbed Header
#
PAGEHEADER("Link Monitoring");

72
echo $experiment->PageHeader();
73 74 75 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 101 102 103 104 105 106 107 108 109
echo "<br /><br />\n";

#
# Give a status message is redirected back here from linkmon_ctl.php3.
#
if (isset($linklan) && $linklan != "" &&
    isset($action) && $action != "") {
    echo "<center><font size=+1>";
    echo "Tracing/Monitoring on $linklan ".
	(isset($vnode) && $vnode != "" ? "($vnode) " : "") . "has been ";
    if ($action == "pause")
	echo "paused";
    elseif ($action == "restart")
	echo "restarted";
    elseif ($action == "snapshot")
	echo "snap shotted";
    elseif ($action == "kill")
	echo "killed";

    echo "</font></center><br>\n";
}

print "<table align=center>\n" .
      "<tr>" .
      " <th rowspan=2>Link Name</th>".
      " <th rowspan=2>Node</th>".
      " <th rowspan=2>Monitor</th>".
      " <td colspan=4 align=center><b>Trace/Monitor</b></th>".
      "</tr><tr>".
      " <th align=center>Pause</th>".
      " <th align=center>Restart</th>".
      " <th align=center>Snapshot</th>".
      " <th align=center>Kill</th>".
      "</tr>";

function SPITMONLINK($vlan, $vnode)
{
110
    global $experiment;
111

112 113
    $url  = CreateURL("linkmon_mon", $experiment, "linklan", $vlan);
    $link = "<a href='$url";
114 115
    if ($vnode)
	$link .= "&vnode=$vnode";
116
    $link .= "' target=_blank>";
117 118 119 120 121 122 123 124
    $link .= "<img border=0 src='/autostatus-icons/blueball.gif' ".
	          "alt='Monitor Link'>";
    $link .= "</a>\n";
    return $link;
}

function SPITTRACELINK($vlan, $vnode, $action, $color)
{
125
    global $experiment;
126

127 128 129
    $url  = CreateURL("linkmon_ctl", $experiment, "linklan", $vlan,
		      "action", $action, "vnode", $vnode);
    $link = "<a href='$url'>";
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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
    $link .= "<img border=0 src='/autostatus-icons/${color}ball.gif' ".
	           "alt='$action'>";
    $link .= "</a>\n";
    return $link;
}

$num  = mysql_num_rows($query_result);
$last = "";
for ($i = 0; $i < $num; $i++) {
    $row = mysql_fetch_array($query_result);

    $vlan   = $row["linkvname"];
    $vnode  = $row["vnode"];

    if (strcmp($last, $vlan)) {
	$last = $vlan;
	echo "<tr>\n";
	echo "  <td><font color=blue>$vlan</font></td>\n";
	echo "  <td><font color=red>All Nodes</font></td>\n";
	echo "  <td align=center>&nbsp</td>\n";
	echo "  <td align=center> " .
	    SPITTRACELINK($vlan, null, "pause", "yellow") . "</td>\n";
	echo "  <td align=center> " .
	    SPITTRACELINK($vlan, null, "restart", "green") . "</td>\n";
	echo "  <td align=center> " .
	    SPITTRACELINK($vlan, null, "snapshot", "pink") . "</td>\n";
	echo "  <td align=center> " .
	    SPITTRACELINK($vlan, null, "kill", "red") . "</td>\n";
	echo "</tr>\n";
    }

    echo "<tr>\n";
    echo "  <td>&nbsp</td>\n";
    echo "  <td>$vnode</td>\n";
    echo "  <td align=center> " .
	SPITMONLINK($vlan, $vnode) . "</td>\n";
    echo "  <td align=center> " .
	SPITTRACELINK($vlan, $vnode, "pause", "yellow") . "</td>\n";
    echo "  <td align=center> " .
	SPITTRACELINK($vlan, $vnode, "restart", "green") . "</td>\n";
    echo "  <td align=center> " .
	SPITTRACELINK($vlan, $vnode, "snapshot", "pink") . "</td>\n";
    echo "  <td align=center> " .
	SPITTRACELINK($vlan, $vnode, "kill", "red") . "</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";
echo "<center><font size=-1>".
178
     "The <a href='$WIKIDOCURL/AdvancedExample#Tracing'>".
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
     "Advanced Tutorial</a> has more info on link Tracing/Monitoring\n".
     "</font></center>\n";

echo "<br>
     <blockquote><blockquote>
     <table class=stealth>
     <tr>
       <td><b>Monitor:</b></td>
       <td>
           Bring up a new window, dispaying per-second traffic
                  statistics from the link
       </td>
      </tr>
      <tr>
       <td><b>Pause:</b></td>
       <td>
	   Pause packet capture (and monitoring)
       </td>
      </tr>
      <tr>
       <td><b>Restart:</b></td>
       <td>
	   Restart packet capture (and monitoring)
       </td>
      </tr>
      <tr>
       <td><b>Snapshot:</b></td>
       <td>
	    Close the packet capture files (syncing them to disk)
                and open a new set of files. Capturing continues.
       </td>
      </tr>
      <tr>
       <td><b>Kill:</b></td>
       <td>
	    Tell the packet capture processes to kill themselves. There
                is no way to restart them, except via reboot.
       </td>
     </table>
     <blockquote><blockquote>\n";

PAGEFOOTER();
?>