1 |
import apmon, sys, common
|
2 |
|
3 |
class ApmonIf:
|
4 |
"""
|
5 |
Provides an interface to the Monalisa Apmon python module
|
6 |
"""
|
7 |
def __init__(self, address='http://lxgate35.cern.ch:40808/ApMonConf'):
|
8 |
self._params = {}
|
9 |
self.fName = 'mlCommonInfo'
|
10 |
self._MLaddress = address
|
11 |
self.apm = None
|
12 |
self.apm = self.getApmonInstance()
|
13 |
|
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 |
self.apm.sendParameters(self._params['taskId'], self._params['jobId'], self._params)
|
22 |
|
23 |
def getApmonInstance(self):
|
24 |
if self.apm is None :
|
25 |
try:
|
26 |
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 |
except:
|
32 |
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 |
|
38 |
def free(self):
|
39 |
self.apm.free()
|