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
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user