add a better bmlog history ; better late than never.
[monitor.git] / rt.py
diff --git a/rt.py b/rt.py
index 4a9c3fd..8194036 100644 (file)
--- a/rt.py
+++ b/rt.py
@@ -7,15 +7,12 @@ import logging
 import Queue
 import time 
 import re
-import comon
-import soltesz
+import database
 from threading import *
+import config
 
 # TODO: merge the RT mailer from mailer.py into this file.
 
-# RT database access constants file
-RT_DB_CONSTANTS_PATH='rt_db'
-
 #Logging
 logger = logging.getLogger("monitor")
 
@@ -69,17 +66,17 @@ def readConstantsFile( file_path ):
 def open_rt_db():
 
        # read plc database passwords and connect
-       rt_db_constants= readConstantsFile(RT_DB_CONSTANTS_PATH)
-       if rt_db_constants is None:
-               print "Unable to read database access constants from %s" % \
-                         RT_DB_CONSTANTS_PATH
-               return -1
+       #rt_db_constants= readConstantsFile(RT_DB_CONSTANTS_PATH)
+       #if rt_db_constants is None:
+       #       print "Unable to read database access constants from %s" % \
+       #                 RT_DB_CONSTANTS_PATH
+       #       return -1
 
        try:
-               rt_db = MySQLdb.connect(host=rt_db_constants['RT_DB_HOST'],
-                               user=rt_db_constants['RT_DB_USER'],
-                               passwd=rt_db_constants['RT_DB_PASSWORD'],
-                               db=rt_db_constants['RT_DB_NAME'])
+               rt_db = MySQLdb.connect(host=config.RT_DB_HOST,
+                                                               user=config.RT_DB_USER,
+                                                               passwd=config.RT_DB_PASSWORD,
+                                                               db=config.RT_DB_NAME)
        except Exception, err:
                print "Failed to connect to RT database: %s" %err
                return -1
@@ -173,7 +170,7 @@ def rt_tickets():
        idTickets = {}
        for t in tickets_all:
                idTickets[t['ticket_id']] = t
-       soltesz.dbDump("idTickets", idTickets)
+       database.dbDump("idTickets", idTickets)
 
        return tickets
 
@@ -206,7 +203,7 @@ def is_host_in_rt_tickets(host, ticket_blacklist, ad_rt_tickets):
                return (False, None)
 
        # This search, while O(tickets), takes less than a millisecond, 05-25-07
-       #t = soltesz.MyTimer()
+       #t = commands.MyTimer()
        ret = search_tickets(host, ad_rt_tickets)
        #del t
 
@@ -312,7 +309,7 @@ def main():
        logger.addHandler(ch)
 
        tickets = rt_tickets()
-       soltesz.dbDump("ad_dbTickets", tickets)
+       database.dbDump("ad_dbTickets", tickets)
 
 
 if __name__ == '__main__':