def monitorhosts(hosts=5, sched='cfs'):
 mytopo = SingleSwitchTopo(hosts)
 cpu = (0.5 / hosts)
 myhost = custom(CPULimitedHost, cpu=cpu, sched=sched)
 net = Mininet(topo=mytopo, host=myhost)
 net.start()
 popens = {}
 last = net.hosts[(-1)]
 for host in net.hosts:
  popens[host] = host.popen(('ping -c5 %s' % last.IP()))
  last = host
 for (host, line) in pmonitor(popens):
  if host:
   info(('<%s>: %s' % (host.name, line)))
 net.stop()

def monitorhosts ( hosts = 5 , sched = 'cfs' ) : mytopo = SingleSwitchTopo ( hosts ) cpu = ( 0.5 / hosts ) myhost = custom ( CPULimitedHost , cpu = cpu , sched = sched ) net = Mininet ( topo = mytopo , host = myhost ) net . start ( ) popens = { } last = net . hosts [ ( - 1 ) ] for host in net . hosts : popens [ host ] = host . popen ( ( 'ping -c5 %s' % last . IP ( ) ) ) last = host for ( host , line ) in pmonitor ( popens ) : if host : info ( ( '<%s>: %s' % ( host . name , line ) ) ) net . stop ( )
start a bunch of pings and monitor them using popen .