X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=diagnose.py;h=ca4345e326b9bc3cef317d43fd5f1093d55fd24b;hb=c3f2afdc81c6711c3825c82e2cd4970671575438;hp=7668e889d53239d7314d71d0243e7cc0497ce592;hpb=b75d6695261020e52d87363012e5b8b9ad9e900c;p=monitor.git diff --git a/diagnose.py b/diagnose.py index 7668e88..ca4345e 100755 --- a/diagnose.py +++ b/diagnose.py @@ -15,9 +15,8 @@ import Queue from sets import Set # Global config options -from config import config -from optparse import OptionParser -parser = OptionParser() +import parser as parsermodule +parser = parsermodule.getParser() parser.set_defaults(nodelist=None, refresh=False, @@ -39,8 +38,7 @@ parser.add_option("", "--ticketlist", dest="ticketlist", parser.add_option("", "--blacklist", dest="blacklist", help="Blacklist all nodes in this file") -config = config(parser) -config.parse_args() +config = parsermodule.parse_args(parser) # daemonize and *pid #from util.process import * @@ -49,7 +47,8 @@ config.parse_args() import rt # Correlates input with policy to form actions import policy -import soltesz +import moncommands +import database import plc import syncplcdb @@ -66,7 +65,7 @@ POLSLEEP=10 # list will be monitored. runningthreads = {} # Seconds between checking threads -WATCHSLEEP = 10 +WATCHSLEEP = 5 # Set up Logging logger = logging.getLogger("monitor") @@ -153,7 +152,7 @@ def main(): ######### GET NODES ######################################## logger.info('Get Nodes from PLC') print "getnode from plc: %s %s %s" % (config.debug, config.cachenodes, config.refresh) - l_plcnodes = soltesz.if_cached_else_refresh(config.cachenodes, + l_plcnodes = database.if_cached_else_refresh(config.cachenodes, config.refresh, "l_plcnodes", lambda : syncplcdb.create_plcdb() ) @@ -179,14 +178,14 @@ def main(): print "len of l_nodes: %d" % len(l_nodes) # Minus blacklisted ones.. - l_blacklist = soltesz.if_cached_else(1, "l_blacklist", lambda : []) - l_ticket_blacklist = soltesz.if_cached_else(1,"l_ticket_blacklist",lambda : []) + l_blacklist = database.if_cached_else(1, "l_blacklist", lambda : []) + l_ticket_blacklist = database.if_cached_else(1,"l_ticket_blacklist",lambda : []) l_nodes = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes) logger.info('Get Tickets from RT') ####### RT tickets ######################################### - t = soltesz.MyTimer() - ad_dbTickets = soltesz.if_cached_else_refresh(config.cachert, config.refresh, "ad_dbTickets", rt.rt_tickets) + t = moncommands.MyTimer() + ad_dbTickets = database.if_cached_else_refresh(config.cachert, config.refresh, "ad_dbTickets", rt.rt_tickets) if ad_dbTickets == "": print "ad_dbTickets failed..." sys.exit(1)