Skip to content
Snippets Groups Projects
Commit 1bf1a4d5 authored by Bob Lantz's avatar Bob Lantz
Browse files

Tag node bash processes and add attach script

Try invoking bash processes with -s mininet:host,
for easy identification of hosts. This enables
easy attachment using the util/m script.
closes #121
parent a0f69d98
No related branches found
No related tags found
No related merge requests found
...@@ -27,12 +27,15 @@ def cleanup(): ...@@ -27,12 +27,15 @@ def cleanup():
info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes" info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes"
"\n") "\n")
zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core ' zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core '
zombies += 'ovs-openflowd udpbwtest' zombies += 'ovs-openflowd udpbwtest mnexec'
# Note: real zombie processes can't actually be killed, since they # Note: real zombie processes can't actually be killed, since they
# are already (un)dead. Then again, # are already (un)dead. Then again,
# you can't connect to them either, so they're mostly harmless. # you can't connect to them either, so they're mostly harmless.
sh( 'killall -9 ' + zombies + ' 2> /dev/null' ) sh( 'killall -9 ' + zombies + ' 2> /dev/null' )
# And kill off sudo mnexec
sh( 'pkill -9 -f "sudo mnexec"')
info( "*** Removing junk from /tmp\n" ) info( "*** Removing junk from /tmp\n" )
sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' ) sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' )
......
...@@ -118,7 +118,8 @@ def startShell( self ): ...@@ -118,7 +118,8 @@ def startShell( self ):
if self.inNamespace: if self.inNamespace:
opts += 'n' opts += 'n'
# bash -m: enable job control # bash -m: enable job control
cmd = [ 'mnexec', opts, 'bash', '-m' ] # -s: pass $* to shell, and make process easy to find in ps
cmd = [ 'mnexec', opts, 'bash', '-ms', 'mininet:' + self.name ]
self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, self.shell = Popen( cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
close_fds=True ) close_fds=True )
self.stdin = self.shell.stdin self.stdin = self.shell.stdin
......
util/m 0 → 100755
#!/bin/bash
# Attach to a Mininet host and run a command
if [ -z $1 ]; then
echo "usage: $0 host cmd [args...]"
exit 1
else
host=$1
fi
pid=`pgrep -f mininet:$host`
if [ "$pid" == "" ]; then
echo "Could not find Mininet host $host"
exit 2
fi
if [ -z $2 ]; then
cmd='bash'
else
shift
cmd=$*
fi
cgroup=/sys/fs/cgroup/cpu/$host
if [ -d "$cgroup" ]; then
cg="-g $host"
fi
exec sudo mnexec -a $pid $cg $cmd
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment