| This example monitors a number of hosts using host.popen() and |
| from mininet.net import Mininet |
| from mininet.node import CPULimitedHost |
| from mininet.topo import SingleSwitchTopo |
| from mininet.log import setLogLevel |
| from mininet.util import custom, pmonitor |
| def monitorhosts( hosts=5, sched='cfs' ): |
| "Start a bunch of pings and monitor them using popen" |
| mytopo = SingleSwitchTopo( hosts ) |
| myhost = custom( CPULimitedHost, cpu=cpu, sched=sched ) |
| net = Mininet( topo=mytopo, host=myhost ) |
| popens[ host ] = host.popen( "ping -c5 %s" % last.IP() ) |
| # Monitor them and print output |
| for host, line in pmonitor( popens ): |
| print "<%s>: %s" % ( host.name, line.strip() ) |
| if __name__ == '__main__': |