Commit 7942119e authored by Leigh Stoller's avatar Leigh Stoller

Added my simplistic link tracing and monitoring. Example usage and

some details can be found in the advanced tutorial that I wrote up.
See this link:

http://www.emulab.net/tutorial/docwrapper.php3?docname=advanced.html#Tracing

The basic idea is that each virt_lan entry gets a couple of new slots
describing the type of tracing that is desired.

  traced tinyint(1) default '0',
  trace_type enum('header','packet','monitor') NOT NULL default 'header',
  trace_expr tinytext,
  trace_snaplen int(11) NOT NULL default '0',
  trace_endnode tinyint(1) NOT NULL default '0',

There is a new physical table called "traces" that is a little bit
like the current delays table. A new tmcd command returns the trace
configuration to the client nodes (tmcd/common/config/rc.trace).

The delays table got a new boolean called "noshaping" that tells the
delay node to bridge, but not set up any pipes. This allows us to
capture traffic at the delay node, but without much less overhead on
the packets.

The pcapper got bloated up to do packet capture and more event stuff.
I also had to add some mutex locking around calls into the pcap
library and around malloc, since the current setup used linuxthreads,
which is not compatable with the standard libc_r library. I was
getting all kinds of memory corruption, and I am sure that if someone
breathes on the pcapper again, it will break in some new way.
parent 73303982
......@@ -3236,6 +3236,7 @@ sub TBRobotLabExpt($$)
"ipport_ranges",
"v2pmap",
"linkdelays",
"traces",
"portmap");
#
......
......@@ -145,6 +145,7 @@ CREATE TABLE delays (
vnode1 varchar(32) default NULL,
card0 tinyint(3) unsigned default NULL,
card1 tinyint(3) unsigned default NULL,
noshaping tinyint(1) default '0',
PRIMARY KEY (node_id,iface0,iface1),
KEY pid (pid,eid)
) TYPE=MyISAM;
......@@ -1709,6 +1710,26 @@ CREATE TABLE tmcd_redirect (
PRIMARY KEY (node_id)
) TYPE=MyISAM;
--
-- Table structure for table `traces`
--
CREATE TABLE traces (
node_id varchar(32) NOT NULL default '',
idx int(10) unsigned NOT NULL auto_increment,
iface0 varchar(8) NOT NULL default '',
iface1 varchar(8) NOT NULL default '',
pid varchar(32) default NULL,
eid varchar(32) default NULL,
linkvname varchar(32) default NULL,
vnode varchar(32) default NULL,
trace_type tinytext,
trace_expr tinytext,
trace_snaplen int(11) NOT NULL default '0',
PRIMARY KEY (node_id,idx),
KEY pid (pid,eid)
) TYPE=MyISAM;
--
-- Table structure for table `tunnels`
--
......@@ -2052,6 +2073,11 @@ CREATE TABLE virt_lans (
trivial_ok tinyint(4) default '1',
protocol varchar(30) NOT NULL default 'ethernet',
is_accesspoint tinyint(4) default '0',
traced tinyint(1) default '0',
trace_type enum('header','packet','monitor') NOT NULL default 'header',
trace_expr tinytext,
trace_snaplen int(11) NOT NULL default '0',
trace_endnode tinyint(1) NOT NULL default '0',
KEY pid (pid,eid,vname),
KEY vnode (pid,eid,vnode)
) TYPE=MyISAM;
......
......@@ -571,6 +571,11 @@ REPLACE INTO table_regex VALUES ('virt_lans','uselinkdelay','int','redirect','de
REPLACE INTO table_regex VALUES ('virt_lans','nobwshaping','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','usevethiface','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','trivial_ok','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','traced','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','trace_type','text','regex','^(header|packet|monitor)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','trace_expr','text','redirect','default:text',1,255,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','trace_snaplen','int','redirect','default:int',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','trace_endnode','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('virt_node_desires','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_desires','eid','text','redirect','experiments:eid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_desires','vname','text','redirect','virt_nodes:vname',0,0,NULL);
......
......@@ -2667,3 +2667,39 @@ last_net_act,last_cpu_act,last_ext_act);
distance_remaining float default NULL,
PRIMARY KEY (node_id)
) TYPE=MyISAM;
1.339: Add stuff for tracing links and lans.
alter table virt_lans add traced tinyint(1) default '0' \
after is_accesspoint;
alter table virt_lans add trace_type \
enum('header','packet','monitor') NOT NULL default 'header' \
after traced;
alter table virt_lans add trace_expr tinytext \
after trace_type;
alter table virt_lans add trace_snaplen \
int(11) NOT NULL default '0' \
after trace_expr;
alter table virt_lans add trace_endnode \
tinyint(1) NOT NULL default '0' \
after trace_snaplen;
alter table delays add noshaping tinyint(1) default '0' \
after card1;
CREATE TABLE traces (
node_id varchar(32) NOT NULL default '',
idx int(10) unsigned NOT NULL auto_increment,
iface0 varchar(8) NOT NULL default '',
iface1 varchar(8) NOT NULL default '',
pid varchar(32) default NULL,
eid varchar(32) default NULL,
linkvname varchar(32) default NULL,
vnode varchar(32) default NULL,
trace_type tinytext,
trace_expr tinytext,
trace_snaplen int(11) NOT NULL default '0',
PRIMARY KEY (node_id,idx),
KEY pid (pid,eid)
) TYPE=MyISAM;
......@@ -10,11 +10,8 @@
INSERT INTO sitevariables VALUES ('general/testvar',NULL,'43','A test variable');
INSERT INTO sitevariables VALUES ('general/firstinit/state',NULL,'Ready','Indicates that a new emulab is not setup yet. Moves through several states.');
INSERT INTO sitevariables VALUES ('general/firstinit/pid',NULL,'testbed','The Project Name of the first project.');
INSERT INTO sitevariables VALUES ('web/nologins',NULL,'0','Non-zero value indicates that no user may log into the Web Interface; non-admin users are auto logged out.');
INSERT INTO sitevariables VALUES ('web/message',NULL,'','Message to place in large lettering under the login message on the Web Interface.');
INSERT INTO sitevariables VALUES ('web/banner',NULL,'','Message to place in large lettering at top of home page (typically a special message)');
INSERT INTO sitevariables VALUES ('idle/threshold',NULL,'4','Number of hours of inactivity for a node/expt to be considered idle.');
INSERT INTO sitevariables VALUES ('idle/mailinterval',NULL,'4','Number of hours since sending a swap request before sending another one. (Timing of first one is determined by idle/threshold.)');
INSERT INTO sitevariables VALUES ('idle/cc_grp_ldrs',NULL,'3','Start CC\'ing group and project leaders on idle messages on the Nth message.');
......@@ -25,9 +22,9 @@ INSERT INTO sitevariables VALUES ('plab/stale_age',NULL,'60','Age in minutes at
INSERT INTO sitevariables VALUES ('idle/batch_threshold',NULL,'30','Number of minutes of inactivity for a batch node/expt to be considered idle.');
INSERT INTO sitevariables VALUES ('general/recently_active',NULL,'14','Number of days to be considered a recently active user of the testbed.');
INSERT INTO sitevariables VALUES ('plab/load_metric',NULL,'load_fifteen','GMOND load metric to use (load_one, load_five, load_fifteen)');
INSERT INTO sitevariables VALUES ('plab/max_load',NULL,'5.0','Load at which to stop admitting jobs (0==admit nothing, 1000==admit all)');
INSERT INTO sitevariables VALUES ('plab/max_load','10','5.0','Load at which to stop admitting jobs (0==admit nothing, 1000==admit all)');
INSERT INTO sitevariables VALUES ('plab/min_disk',NULL,'10.0','Minimum disk space free at which to stop admitting jobs (0==admit all, 100==admit none)');
INSERT INTO sitevariables VALUES ('watchdog/interval',NULL,'60','Interval in minutes between checks for changes in timeout values (0==never check)');
INSERT INTO sitevariables VALUES ('watchdog/interval','30','60','Interval in minutes between checks for changes in timeout values (0==never check)');
INSERT INTO sitevariables VALUES ('watchdog/ntpdrift',NULL,'240','Interval in minutes between reporting back NTP drift changes (0==never report)');
INSERT INTO sitevariables VALUES ('watchdog/cvsup',NULL,'720','Interval in minutes between remote node checks for software updates (0==never check)');
INSERT INTO sitevariables VALUES ('watchdog/isalive/local',NULL,'3','Interval in minutes between local node status reports (0==never report)');
......@@ -37,26 +34,30 @@ INSERT INTO sitevariables VALUES ('watchdog/isalive/wa',NULL,'1','Interval in mi
INSERT INTO sitevariables VALUES ('watchdog/isalive/dead_time',NULL,'120','Time, in minutes, after which to consider a node dead if it has not checked in via tha watchdog');
INSERT INTO sitevariables VALUES ('plab/setup/vnode_batch_size',NULL,'40','Number of plab nodes to setup simultaneously');
INSERT INTO sitevariables VALUES ('plab/setup/vnode_wait_time',NULL,'960','Number of seconds to wait for a plab node to setup');
INSERT INTO sitevariables VALUES ('watchdog/rusage',NULL,'1','Interval in minutes between node resource usage reports (0==never report)');
INSERT INTO sitevariables VALUES ('watchdog/rusage','5','1','Interval in minutes between node resource usage reports (0==never report)');
INSERT INTO sitevariables VALUES ('watchdog/hostkeys',NULL,'999999','Interval in minutes between host key reports (0=never report, 999999=once only)');
INSERT INTO sitevariables VALUES ('plab/message',NULL,'','Message to display at the top of the plab_ez page');
INSERT INTO sitevariables VALUES ('node/ssh_pubkey',NULL,'','Boss SSH public key to install on nodes');
INSERT INTO sitevariables VALUES ('plab/message','Planetlab support is currently broken due to API incompatibilities introduced into PLC.','','Message to display at the top of the plab_ez page');
INSERT INTO sitevariables VALUES ('node/ssh_pubkey','1024 37 168728947415883137658395816497236019932357443574364998989351516015013006429180411438552594116282442938932702706360430451154958992295988097967662214818020771421328881173382895214540694120581207714991274873698590147743427181599852480329442016838781882554809552882295931111276319070960396053057987057937216750401 root@paper.cs.utah.edu','','Boss SSH public key to install on nodes');
INSERT INTO sitevariables VALUES ('web/banner',NULL,'','Message to place in large lettering at top of home page (typically a special message)');
INSERT INTO sitevariables VALUES ('general/autoswap_threshold',NULL,'16','Number of hours before an experiment is forcibly swapped');
INSERT INTO sitevariables VALUES ('general/autoswap_mode',NULL,'0','Control whether autoswap defaults to on or off in the Begin Experiment page');
INSERT INTO sitevariables VALUES ('webcam/anyone_can_view',NULL,'0','Turn webcam viewing on/off for mere users; default is off');
INSERT INTO sitevariables VALUES ('general/autoswap_mode','1','0','Control whether autoswap defaults to on or off in the Begin Experiment page');
INSERT INTO sitevariables VALUES ('webcam/anyone_can_view','1','0','Turn webcam viewing on/off for mere users; default is off');
INSERT INTO sitevariables VALUES ('webcam/admins_can_view',NULL,'1','Turn webcam viewing on/off for admin users; default is on');
INSERT INTO sitevariables VALUES ('swap/use_admission_control',NULL,'1','Use admission control when swapping in experiments');
INSERT INTO sitevariables VALUES ('swap/admission_control_debug',NULL,'0','Turn on/off admission control debugging (lots of output!)');
INSERT INTO sitevariables VALUES ('robotlab/override',NULL,'','Turn the Robot Lab on/off (open/close). This is an override over other settings');
INSERT INTO sitevariables VALUES ('robotlab/override','','','Turn the Robot Lab on/off (open/close). This is an override over other settings');
INSERT INTO sitevariables VALUES ('robotlab/exclusive',NULL,'1','Only one experiment at a time; do not turn this off!');
INSERT INTO sitevariables VALUES ('robotlab/opentime',NULL,'07:00','Time the Robot lab opens for use.');
INSERT INTO sitevariables VALUES ('robotlab/opentime','08:00','07:00','Time the Robot lab opens for use.');
INSERT INTO sitevariables VALUES ('robotlab/closetime',NULL,'18:00','Time the Robot lab closes down for the night.');
INSERT INTO sitevariables VALUES ('robotlab/open',NULL,'0','Turn the Robot Lab on/off for weekends and holidays. Overrides the open/close times.');
INSERT INTO sitevariables VALUES ('elabinelab/boss_pkg',NULL,'','Name of boss node install package');
INSERT INTO sitevariables VALUES ('elabinelab/boss_pkg_dir',NULL,'','Path from which to fetch boss packages');
INSERT INTO sitevariables VALUES ('elabinelab/ops_pkg',NULL,'','Name of ops node install package');
INSERT INTO sitevariables VALUES ('elabinelab/ops_pkg_dir',NULL,'','Path from which to fetch ops packages');
INSERT INTO sitevariables VALUES ('elabinelab/windows',NULL,'0','Turn on Windows support in inner Emulab');
INSERT INTO sitevariables VALUES ('general/version/major',NULL,'','Source code major revision number');
INSERT INTO sitevariables VALUES ('general/version/minor',NULL,'','Source code minor revision number');
INSERT INTO sitevariables VALUES ('general/version/build',NULL,'','Build version number');
INSERT INTO sitevariables VALUES ('robotlab/open','1','0','Turn the Robot Lab on/off for weekends and holidays. Overrides the open/close times.');
INSERT INTO sitevariables VALUES ('swap/admission_control_debug',NULL,'0','Turn on/off admission control debugging (lots of output!)');
INSERT INTO sitevariables VALUES ('elabinelab/boss_pkg','emulab-boss-1.8','','Name of boss node install package');
INSERT INTO sitevariables VALUES ('elabinelab/boss_pkg_dir','/share/freebsd/packages/FreeBSD-4.10-20041102','','Path from which to fetch boss packages');
INSERT INTO sitevariables VALUES ('elabinelab/ops_pkg','emulab-ops-1.4','','Name of ops node install package');
INSERT INTO sitevariables VALUES ('elabinelab/ops_pkg_dir','/share/freebsd/packages/FreeBSD-4.10-20041102','','Path from which to fetch ops packages');
INSERT INTO sitevariables VALUES ('elabinelab/windows','1','0','Turn on Windows support in inner Emulab');
INSERT INTO sitevariables VALUES ('general/firstinit/state',NULL,'Ready','Indicates that a new emulab is not setup yet. Moves through several states.');
INSERT INTO sitevariables VALUES ('general/firstinit/pid',NULL,'testbed','The Project Name of the first project.');
INSERT INTO sitevariables VALUES ('general/version/minor','456','','Source code minor revision number');
INSERT INTO sitevariables VALUES ('general/version/build','06/17/2005','','Build version number');
INSERT INTO sitevariables VALUES ('general/version/major','1','','Source code major revision number');
This diff is collapsed.
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -60,6 +60,12 @@ Queue instproc init {link type node} {
$self set gentle_ 0
$self set red_ 0
$self set traced 0
$self set trace_type "header"
$self set trace_expr {}
$self set trace_snaplen 0
$self set trace_endnode 0
#
# These are NS variables for queues (with NS defaults).
#
......@@ -117,6 +123,21 @@ Queue instproc agent_name {} {
return "$mylink-$mynode"
}
# Turn on tracing.
Queue instproc trace {{ttype "header"} {texpr ""}} {
$self instvar traced
$self instvar trace_expr
$self instvar trace_type
if {$texpr == ""} {
set texpr {}
}
set traced 1
set trace_type $ttype
set trace_expr $texpr
}
#
# A queue is associated with a node on a link. Return that node.
#
......@@ -269,6 +290,64 @@ LanLink instproc mustdelay {} {
set mustdelay 1
}
#
# Set up tracing.
#
Lan instproc trace {{ttype "header"} {texpr ""}} {
$self instvar nodelist
$self instvar linkq
foreach nodeport $nodelist {
set linkqueue $linkq($nodeport)
$linkqueue trace $ttype $texpr
}
}
Link instproc trace {{ttype "header"} {texpr ""}} {
$self instvar toqueue
$self instvar fromqueue
$toqueue trace $ttype $texpr
$fromqueue trace $ttype $texpr
}
Lan instproc trace_snaplen {len} {
$self instvar nodelist
$self instvar linkq
foreach nodeport $nodelist {
set linkqueue $linkq($nodeport)
$linkqueue set trace_snaplen $len
}
}
Link instproc trace_snaplen {$len} {
$self instvar toqueue
$self instvar fromqueue
$toqueue set trace_snaplen $len
$fromqueue set trace_snaplen $len
}
Lan instproc trace_endnode {onoff} {
$self instvar nodelist
$self instvar linkq
foreach nodeport $nodelist {
set linkqueue $linkq($nodeport)
$linkqueue set trace_endnode $onoff
}
}
Link instproc trace_endnode {$onoff} {
$self instvar toqueue
$self instvar fromqueue
$toqueue set trace_endnode $onoff
$fromqueue set trace_endnode $onoff
}
# get_port <node>
# This takes a node and returns the port that the node is connected
# to the LAN with. If a node is in a LAN multiple times for some
......@@ -633,6 +712,15 @@ Link instproc updatedb {DB} {
lappend fields "rest_bandwidth"
}
# Tracing.
if {[$linkqueue set traced] == 1} {
lappend fields "traced"
lappend fields "trace_type"
lappend fields "trace_expr"
lappend fields "trace_snaplen"
lappend fields "trace_endnode"
}
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok $node $port $ip $mustdelay]
if { [info exists ebandwidth($nodeport)] } {
......@@ -643,6 +731,15 @@ Link instproc updatedb {DB} {
lappend values $rebandwidth($nodeport)
}
# Tracing.
if {[$linkqueue set traced] == 1} {
lappend values [$linkqueue set traced]
lappend values [$linkqueue set trace_type]
lappend values [$linkqueue set trace_expr]
lappend values [$linkqueue set trace_snaplen]
lappend values [$linkqueue set trace_endnode]
}
$sim spitxml_data "virt_lans" $fields $values
}
}
......@@ -761,6 +858,15 @@ Lan instproc updatedb {DB} {
if { [info exists rebandwidth($nodeport)] } {
lappend fields "rest_bandwidth"
}
# Tracing.
if {[$linkqueue set traced] == 1} {
lappend fields "traced"
lappend fields "trace_type"
lappend fields "trace_expr"
lappend fields "trace_snaplen"
lappend fields "trace_endnode"
}
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok $protocol $is_accesspoint $node $port $ip $mustdelay]
......@@ -772,6 +878,15 @@ Lan instproc updatedb {DB} {
lappend values $rebandwidth($nodeport)
}
# Tracing.
if {[$linkqueue set traced] == 1} {
lappend values [$linkqueue set traced]
lappend values [$linkqueue set trace_type]
lappend values [$linkqueue set trace_expr]
lappend values [$linkqueue set trace_snaplen]
lappend values [$linkqueue set trace_endnode]
}
$sim spitxml_data "virt_lans" $fields $values
foreach setting_key [array names member_settings] {
......
......@@ -1169,6 +1169,9 @@ Simulator instproc make_event {outer event} {
"Link" -
"Lan" {
set otype LINK
set vnode {}
set vname $obj
switch -- $cmd {
"up" {set etype UP}
"down" {set etype DOWN}
......@@ -1204,13 +1207,28 @@ Simulator instproc make_event {outer event} {
set args "PLR=$plr"
set etype MODIFY
}
"trace" {
set otype LINKTRACE
set vname "${obj}-tracemon"
if {[llength $event] < 3} {
perror "Wrong number of arguments: at $time $event"
return
}
set action [lindex $event 2]
switch -- $action {
"pause" {set etype STOP}
"restart" {set etype START}
"kill" {set etype KILL}
"snapshot" {set etype SNAPSHOT}
}
}
unknown {
punsup "at $time $event"
return
}
}
set vnode {}
set vname $obj
$obj mustdelay
}
"Node" {
......@@ -1287,6 +1305,8 @@ Simulator instproc make_event {outer event} {
set otype LINK
set node [$obj get_node]
set lanlink [$obj get_link]
set vnode {}
set vname "$lanlink-$node"
$lanlink mustdelay
switch -- $cmd {
"set" {
......@@ -1325,13 +1345,28 @@ Simulator instproc make_event {outer event} {
}
}
}
"trace" {
set otype LINKTRACE
set vname "${vname}-tracemon"
if {[llength $event] < 3} {
perror "Wrong number of arguments: at $time $event"
return
}
set action [lindex $event 2]
switch -- $action {
"pause" {set etype STOP}
"restart" {set etype START}
"kill" {set etype KILL}
"snapshot" {set etype SNAPSHOT}
}
}
unknown {
punsup "at $time $event"
return
}
}
set vnode {}
set vname "$lanlink-$node"
}
"Program" {
set otype PROGRAM
......
......@@ -416,6 +416,31 @@ if ($showlinks) {
print "\n";
}
# Trace info.
$result =
DBQueryFatal("select vname,member,trace_type,trace_expr, ".
" trace_snaplen ".
" from virt_lans ".
"where pid='$pid' and eid='$eid' and traced!=0 ".
"order by vname,member");
if ($result->numrows) {
print "Trace/Monitoring Info:\n";
printf "%-15s %-15s %-10s %-7s %s\n",
"ID", "Member", "Type", "Snap", "Expression";
print "--------------- --------------- ---------- ".
"------- ----------------------------\n";
while (($vname,$member,$trace_type,$trace_expr,
$trace_snaplen) = $result->fetchrow_array()) {
printf("%-15s %-15s %-10s %-7s %s\n", $vname, $member,
$trace_type, $trace_snaplen,
(defined($trace_expr) ? $trace_expr : ""));
}
print "\n";
}
#
# Settings.
#
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use Getopt::Std;
......@@ -228,6 +228,13 @@ if (!REMOTE()) {
system("mkextrafs.pl $vndir");
}
#
# Symlink /local into it.
#
if (! -e "/local") {
system("ln -s " . LOCALROOTFS() . " /local");
}
#
# Make sure enough vn devices exist
#
......
......@@ -23,7 +23,7 @@ SCRIPTS = $(addprefix $(SRCDIR)/, \
rc.syncserver rc.linkagent rc.mkelab rc.localize \
rc.keys rc.trafgen rc.tarfiles rc.rpms rc.progagent \
rc.startcmd rc.simulator rc.topomap rc.firewall \
rc.tiptunnels)
rc.tiptunnels rc.trace)
include $(OBJDIR)/Makeconf
......
......@@ -97,7 +97,8 @@ else {
@bootscripts = ("rc.misc", "rc.localize", "rc.keys", "rc.mounts",
"rc.topomap", "rc.accounts",
"rc.route", "rc.tunnels", "rc.ifconfig", "rc.delays",
"rc.hostnames", "rc.syncserver", "rc.trafgen",
"rc.hostnames", "rc.trace",
"rc.syncserver", "rc.trafgen",
"rc.tarfiles", "rc.rpms", "rc.progagent", "rc.linkagent",
"rc.tiptunnels", "rc.startcmd", "rc.simulator");
}
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use POSIX qw(setsid);
sub usage()
{
print "Usage: " .
scriptname() . " [-j vnodeid] [-r rtabid] ".
"boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "j:r:";
my $action = "boot";
my $vnodeid;
my $rtabid; # Currently ignored.
# Turn off line buffering on output
$| = 1;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# Only root.
if ($EUID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
# Script specific goo.
my $PCAPPER = "/usr/local/etc/emulab/pcapper";
my @childpids = ();
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
use libtmcc;
use librc;
#
# Not all clients support this.
#
exit(0)
if (MFS() || PLAB());
# Now safe to do this since MFS does not have full perl install.
require Socket;
import Socket;
# Protos.
sub doboot();
sub doshutdown();
sub doreconfig();
sub docleanup();
# Parse command line.
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'j'})) {
$vnodeid = $options{'j'};
libsetup_setvnodeid($vnodeid);
}
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
# Local goo
# After libsetup include; tcpdumps run outside vnodes.
my $PIDFILE = (defined($vnodeid) ? CONFDIR() : "/var/run") . "/trace.pid";
my $LOGFILE = (defined($vnodeid) ? CONFDIR() : $LOGDIR) . "/trace.debug";
# Execute the action.
SWITCH: for ($action) {
/^boot$/i && do {
doboot();
last SWITCH;
};
/^shutdown$/i && do {
doshutdown();
last SWITCH;
};
/^reconfig$/i && do {
doreconfig();
last SWITCH;
};
/^reset$/i && do {
docleanup();
last SWITCH;
};
fatal("Invalid action: $action\n");
}
exit(0);
# Signal handler to initiate cleanup in parent and the children.
sub Pcleanup($)
{
my ($signame) = @_;
$SIG{TERM} = 'IGNORE';
$SIG{INT} = 'IGNORE';
$SIG{HUP} = 'IGNORE';
foreach my $pid (@childpids) {
print "Send a kill to $pid\n";
system("kill $pid");
waitpid($pid, 0);
}
unlink $PIDFILE;
exit(0);
}
#
# Boot Action.
#
sub doboot()
{
my @traces;
print STDOUT "Checking Testbed trace configuration ... \n";
if (gettraceconfig(\@traces)) {
fatal("Could not get trace configuration from libsetup!");
}
return
if (!@traces);
#
# Create the /local partition to hold the logs, and mkdir the log
# directory. This works on Linux too!
#
if (! JAILED()) {
if (! -d "/local") {
system("mkdir /local") == 0
or fatal("Could not mkdir /local");
system("$BINDIR/mkextrafs.pl -f /local");
}
if (! -d "/local/local") {
fatal("Could not create the /local filesystem");
}
}
if (! -d "/local/logs") {
system("mkdir /local/logs") == 0
or fatal("Could not mkdir /local/logs");
}
#
# Need this for setting up the event sys arguments.
#
my ($pid, $eid, $vname) = check_nickname();
#
# Now daemonize and let the boot continue. We have to disconnect and
# change our session id so that we do not get killed off (nor the tcpdump
# children) when boot script terminates.
#
if (TBBackGround($LOGFILE)) {
sleep(1);
exit(0);
}
# Fully disconnect from bootup.
setsid();
#
# Write our pid to a file so we can be killed later.
#
system("echo '$PID' > $PIDFILE") == 0
or fatal("Could not create $PIDFILE!");
$SIG{TERM} = \&Pcleanup;
$SIG{INT} = \&Pcleanup;
$SIG{HUP} = \&Pcleanup;
foreach my $trace (@traces) {
my $linkname = $trace->{"LINKNAME"};
my $idx = $trace->{"IDX"};
my $mac0 = $trace->{"MAC0"};
my $mac1 = $trace->{"MAC1"};
my $vnode = $trace->{"VNODE"};
my $vnode_mac = $trace->{"VNODE_MAC"};
my $trace_type = $trace->{"TRACE_TYPE"};
my $trace_expr = $trace->{"TRACE_EXPR"};
my $trace_snaplen = $trace->{"TRACE_SNAPLEN"};
my $log = "$LOGDIR/trace_${linkname}-${vnode}.debug";
my $optargs = "";
my $eventargs = "-e $pid/$eid -s localhost";
my $expr = "";
#
# For the event system, listen for events to the entire link/lan,
# and for this node on the link/lan.
#
$eventargs .= " -L ${linkname}-${vnode}-tracemon,${linkname}-tracemon";
#
# User can specify a snaplen. Otherwise, If the trace type is
# "packet" then want a big enough snaplen to get an entire
# ethernet packet.
#
if ($trace_snaplen > 0) {
$optargs .= "-l $trace_snaplen";
}
elsif ($trace_type eq "packet") {
$optargs .= "-l 1518";
}
if ($trace_type eq "packet" || $trace_type eq "header") {