#
# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
#
-# $Id: $
+# $Id: monitor.py,v 1.4 2006/11/14 19:20:13 faiyaza Exp $
import sys
import os
import time
import logging
import Queue
+# Global config options
+import config
# daemonize and *pid
from util.process import *
# Email
import mailer
import emailTxt
-# Defaults
-debug = False
# Log to what
LOG="./monitor.log"
for thread in runningthreads.keys():
# If thread found dead, remove from queue
if not runningthreads[thread].isAlive():
- logger.error("Thread Died: %s" %(thread))
+ logger.error("***********Thread died: %s**********" %(thread))
del runningthreads[thread]
"""
def main():
# Defaults
- global debug, status, logger
+ global status, logger
try:
longopts = ["debug", "status", "help"]
for (opt, optval) in opts:
if opt == "-d" or opt == "--debug":
- debug = True
+ config.debug = True
+ print "Running in DEBUG mode: NO EMAILS SENT AND NO SLICES SQUEEZED."
elif opt == "--status":
#print summary(names)
sys.exit(0)
# The meat of it.
# Nodes to check. Queue of all sick nodes.
- toCheck = Queue.Queue()
+ toCheck = Queue.Queue()
# Nodes that are sick w/o tickets
sickNoTicket = Queue.Queue()
# Comon DB of all nodes
# Nodes that are down. Use this to maintain DB; cleanup.
#alldown = Queue.Queue()
# RT DB
- tickets = {}
+ tickets = {}
# Nodes we've emailed.
# host - > (type of email, time)
emailed = {}
startThread(cm1,"comon")
# Wait for threads to init. Probably should join, but work on that later.
- time.sleep(10)
+ time.sleep(15)
+# while toCheck.empty() == false:
+# time.sleep(10)
+#
# Start Sending Emails
+ time.sleep(30)
startThread(pol, "policy")
-
- # Wait to finish
- while (sickNoTicket.empty() == False) or (toCheck.empty() == False):
- time.sleep(15)
-
-
-
- pol.status()
+ time.sleep(10)
# Store state of emails
- pol.emailedStore("WRITE")
+# pol.emailedStore("WRITE")
# Email what we did.
- pol.status()
+# pol.status()
logger.info('Monitor Exitted')
#if not debug: