Commit 71901cf5 authored by Timothy Stack's avatar Timothy Stack

Add a minor feature to loghole to support network link trace files.

	* utils/loghole.in, utils/loghole.1: Create a directory for traced
	network links that contains symbolic links to the pcap files.

	* www/tutorial/advanced.html: Fix the link to the loghole doc.

	* xmlrpc/emulabserver.py.in: Add a 'traces' aspect to the
	experiment.info method (used by loghole).
parent b622a567
......@@ -199,7 +199,9 @@ action is used to synchronize the logholes on the nodes with the experiment's
log directory on the Emulab users machine. The action will iterate through
each node in the experiment and perform an rsync(1) on the loghole directories
for that node. Currently, the only directories synced are "/var/emulab/logs"
and "/local/logs".
and "/local/logs". In addition, if any of the network links in the experiment
are being traced, the utility will create a directory for each link and setup
symbolic links to the pcap(3) files retrieved from the delay nodes.
.P
Optional arguments:
.TP
......@@ -392,6 +394,14 @@ file:
/proj/\fIpid\fR/exp/\fIeid\fR/logs
The log directory for an experiment.
.TP
/proj/\fIpid\fR/exp/\fIeid\fR/logs/\fInode
The log directory for a node in the experiment.
.TP
/proj/\fIpid\fR/exp/\fIeid\fR/logs/\fIlink
The log directory for a traced LAN or link. The symbolic links in these
directories refer to the pcap(3) files for a node connected to this LAN or
link.
.TP
/local/logs
One of the log directories on experimental nodes that is automatically sync'd.
Users should place any logs/data they want transferred back in this directory.
......@@ -401,7 +411,7 @@ Another log directory on experimental nodes that is automatically sync'd. This
directory usually holds logs generated by the Emulab software running on the
node.
.SH SEE ALSO
event-sched(8), tevc(1), zip(1), rsync(1)
event-sched(8), tevc(1), zip(1), rsync(1), pcap(3)
.SH AUTHOR
The Emulab project at the University of Utah.
.SH NOTES
......
......@@ -9,6 +9,7 @@
import re
import pwd
import sys
import glob
import sets
import stat
import time
......@@ -51,7 +52,7 @@ GLOBAL_LOGS = [
EXTENSIONS = [ ".zip" ]
LINK_DUMP_FMT = [ "%s.xmit", "%s.recv" ]
LINK_DUMP_FMT = [ "trace_%s-%s.xmit", "trace_%s-%s.recv" ]
DOT_LOGHOLES = """+ /var/
+ /var/emulab/
......@@ -917,7 +918,7 @@ def rmstar(host, *args):
#
# @param args Action-specific command line arguments.
#
def do_sync(args, mode="pull", must_be_active=1):
def do_sync(args, mode="sync", must_be_active=1):
from emulabclient import RESPONSE_SUCCESS
global OSIDS, SERVER
......@@ -928,6 +929,7 @@ def do_sync(args, mode="pull", must_be_active=1):
state_method = getattr(SERVER, "experiment.state")
logdir = os.path.join(EXPDIR_FMT % { "PID" : PID, "EID" : EID }, "logs")
os.chdir(logdir)
fp = open(os.path.join(logdir, ".logholes"), "w")
os.chmod(fp.name, 0664)
......@@ -959,21 +961,21 @@ def do_sync(args, mode="pull", must_be_active=1):
"aspect" : "mapping",
})
delays = info_method(PACKAGE_VERSION, {
traces = info_method(PACKAGE_VERSION, {
"proj" : PID,
"exp" : EID,
"aspect" : "delays",
"aspect" : "traces",
})
if ((physical["code"] != RESPONSE_SUCCESS) or
(delays["code"] != RESPONSE_SUCCESS)):
(traces["code"] != RESPONSE_SUCCESS)):
sys.stderr.write("error: xmlrpc failed - %s\n" %
(physical["output"],))
retval = 1
pass
else:
physical = physical["value"]
delays = delays["value"]
traces = traces["value"]
hosts = [(x["node"], x["name"]) for x in physical.values()
if ((x["erole"] == "virthost" or
......@@ -1021,7 +1023,7 @@ def do_sync(args, mode="pull", must_be_active=1):
continue
pass
if mode == "pull":
if mode == "sync":
pid = rsync(phost, os.path.join(logdir, vhost), "/")
pass
elif mode == "clean":
......@@ -1064,11 +1066,42 @@ def do_sync(args, mode="pull", must_be_active=1):
for vhost, sts in hoststatus.items():
if sts not in ACCEPTABLE_RSYNC_STATUS:
sys.stderr.write("error: failed to sync with node '%s'\n" %
vhost)
sys.stderr.write("error: failed to %s node '%s'\n" %
(mode, vhost))
retval = 3
pass
pass
# Add symbolic links to the trace files.
linkdirs = {}
for trace in traces:
fullpath = os.path.join(logdir, trace["linkvname"])
try:
os.makedirs(fullpath)
pass
except OSError:
pass
for fmt in LINK_DUMP_FMT:
src = os.path.join(trace["delayvname"],
"local/logs",
fmt % (trace["vnode"],
trace["linkvname"]))
for filename in glob.glob(src + "*"):
dst = os.path.split(filename)
dst = dst[len(dst) - 1].split('.')
comp = [trace["vnode"]]
comp.extend(dst[1:])
dst = ".".join(comp)
dst = os.path.join(fullpath, dst)
try:
os.unlink(dst)
pass
except OSError:
pass
os.symlink(os.path.join(os.pardir, filename), dst)
pass
pass
pass
pass
pass
......
......@@ -633,8 +633,8 @@ or lan is shaped or not, packets leaving each node are captured twice;
once when they arrive at the delay node, and again when they leave the
delay node. This allows you to precisely monitor how the delay node
affects your packets, whether the link is actually shaped or not.
You can use the <a href=loghole.html>loghole</a> utility to save the
capture files.
You can use the <a href="docwrapper.php3?docname=loghole.html">loghole</a>
utility to copy the capture files back to the experiment's log directory.
<br>
When a link or lan is traced, you may monitor a realtime summary of
......
......@@ -1751,6 +1751,18 @@ class experiment:
pass
pass
elif argdict["aspect"] == "traces":
result = []
dbres = DBQuery("SELECT t.*,r.vname as delayvname "
"FROM traces as t "
"left join reserved as r on t.node_id=r.node_id "
"WHERE r.pid=%s and r.eid=%s",
(argdict["proj"], argdict["exp"]),
asDict=True)
for trace in dbres:
result.append(scrubdict(trace))
pass
pass
return EmulabResponse(RESPONSE_SUCCESS, value=result, output="")
......
Markdown is supported
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