X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bwmon.py;h=0af380da57d254c8682b892290ea90d952a2c622;hb=7c33ef6eebc6b1e32e87d09efc43e20f96bc30f9;hp=ce64322d607e5a9c56ec0e641b9781d096570dbb;hpb=7c7b5a259cdc46faa6dd686acdc1bb597551f055;p=mom.git diff --git a/bwmon.py b/bwmon.py index ce64322..0af380d 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.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 @@ -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.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