diff --git a/mininet/clean.py b/mininet/clean.py index 56ff6ffa498596bda6d226f3f3684c9aa1d58845..07b4d6b9b9de9bde12943272476a3e8f749c3f9d 100755 --- a/mininet/clean.py +++ b/mininet/clean.py @@ -27,12 +27,15 @@ def cleanup(): info("*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes" "\n") 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 # are already (un)dead. Then again, # you can't connect to them either, so they're mostly harmless. sh( 'killall -9 ' + zombies + ' 2> /dev/null' ) + # And kill off sudo mnexec + sh( 'pkill -9 -f "sudo mnexec"') + info( "*** Removing junk from /tmp\n" ) sh( 'rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log' ) diff --git a/mininet/node.py b/mininet/node.py index 47790221496ebc1a99adb06894471d3a218783dc..6275f0cbf4a31040fe4d707409f6ed9dff301dc4 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -118,7 +118,8 @@ def startShell( self ): if self.inNamespace: opts += 'n' # 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, close_fds=True ) self.stdin = self.shell.stdin diff --git a/util/m b/util/m new file mode 100755 index 0000000000000000000000000000000000000000..9757c2ce1af0d865bd74db22ab7c85432a2ac42d --- /dev/null +++ b/util/m @@ -0,0 +1,30 @@ +#!/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