Skip to content

Commit d8137a9

Browse files
author
Nikhil Handigol
committed
do system monitoring only if net.set_debug() is called
1 parent 891ea48 commit d8137a9

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

mininet/net.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
147147
self.numCores = numCores()
148148
self.nextCore = 0 # next core for pinning hosts to CPUs
149149
self.listenPort = listenPort
150-
151-
dt = datetime.now()
152-
self.monitoring = Monitor(output_dir='/tmp/mininet-%s-%s' % (str(dt.date()), str(dt.time())))
150+
self.monitoring = None
153151

154152
self.hosts = []
155153
self.switches = []
@@ -165,6 +163,13 @@ def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
165163
if topo and build:
166164
self.build()
167165

166+
def set_debug(self, output_dir=None):
167+
'''Enable debugging, with output to the specified directory'''
168+
dt = datetime.now()
169+
if not output_dir:
170+
output_dir = '/tmp/mininet-%s-%s' % (str(dt.date()), str(dt.time()))
171+
self.monitoring = Monitor(output_dir=output_dir)
172+
168173
def addHost( self, name, cls=None, **params ):
169174
"""Add host.
170175
name: name of host to add
@@ -346,16 +351,18 @@ def start( self ):
346351
switch.start( self.controllers )
347352
info( '\n' )
348353
info( '*** Starting system monitor\n' )
349-
m = self.monitoring
350-
m.monitors.append(Process(target=m.monitor_cpuacct,
351-
args=(self.hosts, '%s/cpuacct.txt' % m.output_dir)))
352-
m.start()
353-
info( 'Logging monitoring info in: %s\n' % m.output_dir )
354+
if self.monitoring:
355+
m = self.monitoring
356+
m.monitors.append(Process(target=m.monitor_cpuacct,
357+
args=(self.hosts, '%s/cpuacct.txt' % m.output_dir)))
358+
m.start()
359+
info( 'Logging monitoring info in: %s\n' % m.output_dir )
354360

355361
def stop( self ):
356362
"Stop the controller(s), switches and hosts"
357363
info( '*** Stopping system monitor\n' )
358-
self.monitoring.stop()
364+
if self.monitoring:
365+
self.monitoring.stop()
359366
if self.terms:
360367
info( '*** Stopping %i terms\n' % len( self.terms ) )
361368
self.stopXterms()

0 commit comments

Comments
 (0)