ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/ApmonIf.py
Revision: 1.8
Committed: Mon Apr 3 08:58:22 2006 UTC (19 years, 1 month ago) by corvo
Content type: text/x-python
Branch: MAIN
Changes since 1.7: +11 -6 lines
Log Message:
New configuration for apmon instances

File Contents

# User Rev Content
1 corvo 1.8 import apmon, sys, common
2 corvo 1.1
3     class ApmonIf:
4     """
5     Provides an interface to the Monalisa Apmon python module
6     """
7 corvo 1.6 def __init__(self, address='http://lxgate35.cern.ch:40808/ApMonConf'):
8 corvo 1.1 self._params = {}
9 corvo 1.7 self.fName = 'mlCommonInfo'
10 corvo 1.1 self._MLaddress = address
11 corvo 1.2 self.apm = None
12     self.apm = self.getApmonInstance()
13 corvo 1.1
14     def fillDict(self, parr):
15     """
16     Used to fill the dictionary of key/value pair and instantiate the ML client
17     """
18     self._params = parr
19    
20     def sendToML(self):
21 corvo 1.3 self.apm.sendParameters(self._params['taskId'], self._params['jobId'], self._params)
22 corvo 1.2
23     def getApmonInstance(self):
24     if self.apm is None :
25 corvo 1.7 try:
26 corvo 1.8 apmonUrls = ["http://lxgate35.cern.ch:40808/ApMonConf", "http://monalisa.cacr.caltech.edu:40808/ApMonConf"]
27     apmInstance = apmon.ApMon(apmonUrls, apmon.Logger.FATAL);
28     if not apmInstance.initializedOK():
29     print "It seems that ApMon cannot read its configuration. Setting the default destination"
30     apmInstance.setDestinations({'lxgate35.cern.ch:58884': {'sys_monitoring':0, 'general_info':0, 'job_monitoring':1, 'job_interval':300}});
31 corvo 1.7 except:
32 corvo 1.8 exctype, value = sys.exc_info()[:2]
33     print "ApmonIf::getApmonInstance Exception raised %s Value: %s"%(exctype, value)
34     common.logger.message("ApmonIf::getApmonInstance Exception raised: %s %s"%(exctype, value))
35     return
36     return apmInstance
37 corvo 1.4
38     def free(self):
39     self.apm.free()