X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bwmon.py;h=ce33e19bf8fafb94ac21961a84babbc0a229438b;hb=refs%2Fheads%2F1.7;hp=6f5c90e07b317347a059bfaf42c06dbce60d7b0e;hpb=1674a7c141d1faac666cbb62275b64116281004b;p=nodemanager.git diff --git a/bwmon.py b/bwmon.py index 6f5c90e..ce33e19 100644 --- a/bwmon.py +++ b/bwmon.py @@ -648,6 +648,7 @@ def sync(nmdbcopy): pickle.dump((version, slices, deaddb), f) f.close() + def getDefaults(nmdbcopy): ''' Get defaults from default slice's slice attributes. @@ -661,6 +662,7 @@ def getDefaults(nmdbcopy): status = False return status + def allOff(): """ Turn off all slice HTBs @@ -676,7 +678,10 @@ def allOff(): lock = threading.Event() def run(): - """When run as a thread, wait for event, lock db, deep copy it, release it, run bwmon.GetSlivers(), then go back to waiting.""" + """ + When run as a thread, wait for event, lock db, deep copy it, release it, + run bwmon.GetSlivers(), then go back to waiting. + """ logger.log("bwmon: Thread started", 2) while True: lock.wait() @@ -685,8 +690,10 @@ def run(): nmdbcopy = copy.deepcopy(database.db) database.db_lock.release() try: - if getDefaults(nmdbcopy): sync(nmdbcopy) - else: logger.log("bwmon: DISABLED.") + if getDefaults(nmdbcopy) and len(bwlimit.tc("class show dev eth0")) > 0: + # class show to check if net:InitNodeLimit:bwlimit.init has run. + sync(nmdbcopy) + else: logger.log("bwmon: BW limits DISABLED.") except: logger.log_exc() lock.clear()