from Ganga.GPIDev.Base import GangaObject from Ganga.GPIDev.Schema import * from Ganga.GPIDev.Adapters.IMonitoring import IMonitoring from Ganga.Utility.Shell import Shell from Ganga.Utility.Config import getConfig, ConfigError import Ganga.Utility.logging logger = Ganga.Utility.logging.getLogger() import os from Ganga.GPIDev.Lib.File import * from Ganga.Core import FileWorkspace from DashboardAPI import DashboardAPI class ARDADashboard(IMonitoring): """Interface to ARDA dashboard monitoring (with Monalisa)""" _dashboard = DashboardAPI() _schema = Schema(Version(0,0), {}) _name = 'ARDADashboardMonitoring' _hidden = 0 # check that UI has been set up _shell = Shell(getConfig('LCG')['SETUP']) def sandbox(self): return [ File(os.path.join(os.path.dirname(__file__),'apmon.py')), File(os.path.join(os.path.dirname(__file__),'Logger.py')), File(os.path.join(os.path.dirname(__file__),'ProcInfo.py')), File(os.path.join(os.path.dirname(__file__),'report.py')), File(os.path.join(os.path.dirname(__file__),'DashboardAPI.py')) ] def jobsubmitted(self,jobs): nj = 1 for j in jobs: backendname = j.backend._name appname = j.application._name if(appname!='Athena' or backendname != 'LCG'): break dict = {} rc,output,m = self._shell.cmd1('grid-proxy-info -identity 2>/dev/null', allowed_exit=[0,1,256]) if rc: dict['GridUser'] = '' else: dict['GridUser'] = output.strip() # rc,output,m = self._shell.cmd1('whoami 2>/dev/null', # allowed_exit=[0,1,256]) # if rc: # dict['User'] = '' # else: # dict['User'] = output.strip() dict['Application'] = appname dict['ApplicationVersion'] = j.application.atlas_release dict['DatasetName'] = j.inputdata.name() #dict['OwnerName''] = 'unknown' dict['GridJobID'] = j.backend.id dict['Executable'] = 'athena.py' dict['JSTool'] = 'ganga' #dict['NbEvPerRun'] = 12 dict['Scheduler'] = backendname # single to be changed in case of split jobs dict['TaskType'] = 'analysis' dict['VO'] = getConfig('LCG')['VirtualOrganisation'] self._dashboard.sendValues(dict,taskId='todo', jobId=('%d_' + dict['GridJobID']) % (nj) ) print dict nj = nj + 1 monitor = ARDADashboard()