MCPcopy Create free account
hub / github.com/mininet/mininet / monitorhosts

Function monitorhosts

examples/popen.py:13–29  ·  view source on GitHub ↗

Start a bunch of pings and monitor them using popen

( hosts=5 )

Source from the content-addressed store, hash-verified

11from mininet.util import pmonitor
12
13def monitorhosts( hosts=5 ):
14 "Start a bunch of pings and monitor them using popen"
15 mytopo = SingleSwitchTopo( hosts )
16 net = Mininet( topo=mytopo, waitConnected=True )
17 net.start()
18 # Start a bunch of pings
19 popens = {}
20 last = net.hosts[ -1 ]
21 for host in net.hosts:
22 popens[ host ] = host.popen( "ping -c5 %s" % last.IP() )
23 last = host
24 # Monitor them and print output
25 for host, line in pmonitor( popens ):
26 if host:
27 info( "<%s>: %s" % ( host.name, line ) )
28 # Done
29 net.stop()
30
31
32if __name__ == '__main__':

Callers 1

popen.pyFile · 0.85

Calls 7

startMethod · 0.95
stopMethod · 0.95
SingleSwitchTopoClass · 0.90
MininetClass · 0.90
pmonitorFunction · 0.90
popenMethod · 0.45
IPMethod · 0.45

Tested by

no test coverage detected