# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
# Copyright (C) 2004-2006 The Trustees of Princeton University
#
-# $Id: bwmon.py,v 1.15 2006/12/13 21:39:23 faiyaza Exp $
+# $Id: bwmon.py,v 1.19 2007/01/08 21:58:13 faiyaza Exp $
#
import syslog
%(hostname)s to %(class)s destinations
since %(since)s.
-Its maximum %(class)s burst rate will be capped at %(new_maxrate)s
+Its maximum %(class)s burst rate will be capped at %(new_maxrate)s/s
until %(until)s.
Please reduce the average %(class)s transmission rate
-of the slice %(limit)s per %(period)s.
+of the slice to %(limit)s per %(period)s.
""".lstrip()
# If/when PLC switches to byte limits, the avgrates wont be used as
# slice attributes and will return as 0
if (avgrate != 0):
- self.ByteMax = avgrate * period
+ self.ByteMax = int(avgrate * period / 8)
self.ByteThresh = int(self.ByteMax * .8)
if (avgexemptrate != 0):
- self.ExemptByteMax = avgexemptrate * period
+ self.ExemptByteMax = int(avgexemptrate * period / 8)
self.ExemptByteThresh = int(self.ExemptByteMax * .8)
except Exception, err:
# Query Node Manager for max rate overrides
self.updateSliceAttributes()
- if verbose:
- print("\n%s slice attributes "\
- "maxrate %s, maxexemptrate %s" % \
- (self.name,
- bwlimit.format_tc_rate(maxrate),
- bwlimit.format_tc_rate(maxexemptrate)))
-
# Prepare message parameters from the template
message = ""
params = {'slice': self.name, 'hostname': socket.gethostname(),
if bytes >= (self.bytes + self.ByteThresh):
new_maxrate = \
- int((self.ByteMax - self.bytes + bytes)/(period - time.time() - self.time))
+ int(((self.ByteMax - (bytes - self.bytes)) * 8)/(period - int(time.time() - self.time)))
if new_maxrate < default_MinRate:
new_maxrate = default_MinRate
else:
if verbose:
print "%(slice)s %(class)s " \
- "%(bytes)s of %(limit)s (%(new_maxrate)s maxrate)" % \
+ "%(bytes)s of %(limit)s (%(new_maxrate)s/s maxrate)" % \
params
# Cap low bandwidth burst rate
if new_maxrate != maxrate:
message += template % params
- print "%(slice)s %(class)s capped at %(new_maxrate)s " % params
+ print "%(slice)s %(class)s capped at %(new_maxrate)s/s " % params
if exemptbytes >= (self.exemptbytes + self.ExemptByteThresh):
new_maxexemptrate = \
- int((self.ExemptByteMax - (self.bytes + bytes))/(period - (time.time() - self.time)))
+ int(((self.ExemptByteMax - (self.bytes - bytes)) * 8)/(period - int(time.time() - self.time)))
if new_maxexemptrate < default_MinRate:
new_maxexemptrate = default_MinRate
else:
if verbose:
print "%(slice)s %(class)s " \
- "%(bytes)s of %(limit)s (%(new_maxrate)s maxrate)" % params
+ "%(bytes)s of %(limit)s (%(new_maxrate)s/s maxrate)" % params
# Cap high bandwidth burst rate
if new_maxexemptrate != maxexemptrate:
message += template % params
- print "%(slice)s %(class)s capped at %(new_maxexemptrate)s" % params
+ print "%(slice)s %(class)s capped at %(new_maxexemptrate)s/s" % params
# Apply parameters
if new_maxrate != maxrate or new_maxexemptrate != maxexemptrate:
(version, slices) = pickle.load(f)
f.close()
# Check version of data file
- if version != "$Id: bwmon.py,v 1.15 2006/12/13 21:39:23 faiyaza Exp $":
+ if version != "$Id: bwmon.py,v 1.19 2007/01/08 21:58:13 faiyaza Exp $":
print "Not using old version '%s' data file %s" % (version, datafile)
raise Exception
except Exception:
- version = "$Id: bwmon.py,v 1.15 2006/12/13 21:39:23 faiyaza Exp $"
+ version = "$Id: bwmon.py,v 1.19 2007/01/08 21:58:13 faiyaza Exp $"
slices = {}
# Get special slice IDs