3 "Monitor multiple hosts using popen()/pmonitor()"
5 from mininet.net import Mininet
6 from mininet.topo import SingleSwitchTopo
7 from mininet.util import pmonitor
8 from mininet.log import setLogLevel, info
11 from signal import SIGINT
13 def pmonitorTest( N=3, seconds=10 ):
14 "Run pings and monitor multiple hosts using pmonitor"
15 topo = SingleSwitchTopo( N )
19 info( "Starting test...\n" )
23 popens[ h ] = h.popen('ping', server.IP() )
24 info( "Monitoring output for", seconds, "seconds\n" )
25 endTime = time() + seconds
26 for h, line in pmonitor( popens, timeoutms=500 ):
28 info( '<%s>: %s' % ( h.name, line ) )
30 for p in popens.values():
31 p.send_signal( SIGINT )
34 if __name__ == '__main__':