#!/usr/bin/python
#
+# $Id$
+# $URL$
+#
# Average bandwidth monitoring script. Run periodically via NM db.sync to
# enforce a soft limit on daily bandwidth usage for each slice. If a
# slice is found to have transmitted 80% of its daily byte limit usage,
# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
# Copyright (C) 2004-2008 The Trustees of Princeton University
#
-# $Id$
-#
import os
import sys
import time
import pickle
import socket
-import logger
import copy
import threading
-import tools
+import logger
+import tools
import bwlimit
import database
from sets import Set
+priority = 20
+
# Defaults
# Set DEBUG to True if you don't want to send emails
DEBUG = False
if newslice != None and live[newslice].has_key('_rspec') == True:
# Check to see if we recently deleted this slice.
if live[newslice]['name'] not in deaddb.keys():
- logger.log( "bwmon: New Slice %s" % live[newslice]['name'] )
+ logger.log( "bwmon: new slice %s" % live[newslice]['name'] )
# _rspec is the computed rspec: NM retrieved data from PLC, computed loans
# and made a dict of computed values.
slices[newslice] = Slice(newslice, live[newslice]['name'], live[newslice]['_rspec'])
default_xid = bwlimit.get_xid("default")
kernelhtbs = gethtbs(root_xid, default_xid)
if len(kernelhtbs):
- logger.log("bwlimit: Disabling all running HTBs.")
+ logger.log("bwmon: Disabling all running HTBs.")
for htb in kernelhtbs.keys(): bwlimit.off(htb)
# class show to check if net:InitNodeLimit:bwlimit.init has run.
sync(nmdbcopy)
else: logger.log("bwmon: BW limits DISABLED.")
- except: logger.log_exc()
+ except: logger.log_exc("bwmon failed")
lock.clear()
def start(*args):
tools.as_daemon_thread(run)
def GetSlivers(*args):
+ logger.verbose ("bwmon: triggering dummy GetSlivers")
pass