From 69c08c5f1b11b06b937f5ceda811a63676d80f31 Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Wed, 3 Jan 2007 20:15:06 +0000 Subject: [PATCH] * time.time() returns a float which python doesn't like to divide. Fixed. * Made email slightly more readable. --- bwmon.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/bwmon.py b/bwmon.py index ce64322..14c089f 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.16 2006/12/19 16:52:24 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() @@ -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))/(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))/(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.16 2006/12/19 16:52:24 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.16 2006/12/19 16:52:24 faiyaza Exp $" slices = {} # Get special slice IDs -- 2.43.0