def pmonitorTest(N=3, seconds=10):
 topo = SingleSwitchTopo(N)
 net = Mininet(topo)
 net.start()
 hosts = net.hosts
 info('Starting test...\n')
 server = hosts[0]
 popens = {}
 for h in hosts:
  popens[h] = h.popen('ping', server.IP())
 info('Monitoring output for', seconds, 'seconds\n')
 endTime = (time() + seconds)
 for (h, line) in pmonitor(popens, timeoutms=500):
  if h:
   info(('<%s>: %s' % (h.name, line)))
  if (time() >= endTime):
   for p in popens.values():
    p.send_signal(SIGINT)
 net.stop()

def pmonitorTest ( N = 3 , seconds = 10 ) : topo = SingleSwitchTopo ( N ) net = Mininet ( topo ) net . start ( ) hosts = net . hosts info ( 'Starting test...\n' ) server = hosts [ 0 ] popens = { } for h in hosts : popens [ h ] = h . popen ( 'ping' , server . IP ( ) ) info ( 'Monitoring output for' , seconds , 'seconds\n' ) endTime = ( time ( ) + seconds ) for ( h , line ) in pmonitor ( popens , timeoutms = 500 ) : if h : info ( ( '<%s>: %s' % ( h . name , line ) ) ) if ( time ( ) >= endTime ) : for p in popens . values ( ) : p . send_signal ( SIGINT ) net . stop ( )
run pings and monitor multiple hosts using pmonitor .