X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bwmon.py;h=de4c8d2bd6a606a226e5a9ffaf308bbb4494a1b9;hb=refs%2Fheads%2Fplanetlab-3_3-branch;hp=4d76fe09f793c6631f9a0e48a98b6c4025518f91;hpb=27086193cc89538ac9eb0193568a5643a8c3464c;p=mom.git diff --git a/bwmon.py b/bwmon.py index 4d76fe0..de4c8d2 100755 --- a/bwmon.py +++ b/bwmon.py @@ -15,7 +15,7 @@ # Faiyaz Ahmed # Copyright (C) 2004-2006 The Trustees of Princeton University # -# $Id: bwmon.py,v 1.16 2006/12/19 16:52:24 faiyaza Exp $ +# $Id: bwmon.py,v 1.20 2007/01/10 16:51:04 faiyaza Exp $ # import syslog @@ -74,11 +74,11 @@ The slice %(slice)s has transmitted more than %(bytes)s from %(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() @@ -160,11 +160,11 @@ class Slice: # 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: @@ -205,13 +205,6 @@ class Slice: # 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(), @@ -222,7 +215,7 @@ class Slice: 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: @@ -237,17 +230,17 @@ class Slice: 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: @@ -262,12 +255,12 @@ class Slice: 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: @@ -343,11 +336,11 @@ def main(): (version, slices) = pickle.load(f) f.close() # Check version of data file - if version != "$Id: bwmon.py,v 1.16 2006/12/19 16:52:24 faiyaza Exp $": + if version != "$Id: bwmon.py,v 1.20 2007/01/10 16:51:04 faiyaza Exp $": print "Not using old version '%s' data file %s" % (version, datafile) raise Exception except Exception: - version = "$Id: bwmon.py,v 1.16 2006/12/19 16:52:24 faiyaza Exp $" + version = "$Id: bwmon.py,v 1.20 2007/01/10 16:51:04 faiyaza Exp $" slices = {} # Get special slice IDs