Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

HskSvr.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2004
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 __facility__ = "Online"
00011 __abstract__ = "GLAST LAT Housekeeping server infrastructure"
00012 __author__   = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST I&T"
00013 __date__     = "07/28/04"
00014 __version__  = "$Revision: 1.13 $"
00015 __release__  = "$Name: R04-12-00 $"
00016 __credits__  = "SLAC"
00017 
00018 import LATTE.copyright_SLAC
00019 import logging as log
00020 
00021 # Hsk core code
00022 from LATTE.monitoring.HskCollector import *
00023 from LATTE.client.gOptions         import Options
00024 
00025 def alarmSetup(hskDB, cmdDB):
00026   # Retrieve the global rule list for HSK
00027   ruleSet = hskDB.getRules()
00028   # print ruleSet
00029   # Access any of the rule objects and call clearAllActions() to clear actions.
00030   ruleSet.values()[0].clearAllActions()
00031   
00032   # add some trivial yellow/red alarms
00033   from HskAlarms import yellowAlert, redAlert
00034   for key in ruleSet.keys():
00035     ruleSet[key].registerAction('yellowAction', yellowAlert)
00036     ruleSet[key].registerAction('redAction',    redAlert)
00037   
00038 def usage():
00039   return """
00040 
00041 HskSvr Usage:
00042 
00043 Mandatory options:
00044 --config    specify the configuration file to read
00045 
00046 Example:
00047 $ HskSvr --config hskConfig.cfg
00048 
00049 """
00050   
00051 if __name__ == '__main__':
00052   
00053   # Options, first list mandatory, second list optional 
00054   options = Options(['config'])
00055   try:
00056     options.parse()
00057   except Exception, msg:
00058     options.usage(usage())
00059     raise Exception, msg
00060   
00061   # parse config file
00062   # get the configuration and verify that it's consistent
00063   config = HskConfiguration()
00064   config.read(options.config)
00065   config.verify()
00066   
00067   # build the collector from the config
00068   collector = HskCollector(config)
00069   alarmSetup(collector.hskDB(), collector.latDB())
00070   
00071   # turn it on
00072   collector.setAcquiring(True)
00073   
00074   # wait for control-c
00075   from time import sleep
00076   try:
00077     while 1:
00078       sleep(.1)
00079   except Exception, e:
00080     collector.shutdown()
00081   
00082   
00083   
00084   
00085   
00086   
00087   

Generated on Fri Jul 21 13:26:30 2006 for LATTE R04-12-00 by doxygen 1.4.3