if __name__ == "__main__": # check how many getDLSsites.py processed around, if more then 2 send Email to cms-dbs procName='getDLSsites.py' res = popen2.Popen4('ps auxw | grep %s | grep -v grep'%procName) result= res.fromchild.read() nProc = string.count(result,'%s'%procName) if nProc>1: try: hostname = socket.gethostbyaddr(socket.gethostname())[0] except: hostname = 'localhost' pass msg ="At %s found %s %s processes on %s.\n"%(time.asctime(),nProc,procName,hostname) msg+="Please take some action, since it indicates that DLS is not responding.\n" msg+="The %s is a part of DBS data discovery and runs as cronjob on %s."%(procName,hostname) DBSUtil.sendEmail(msg) sys.exit(1) # get grid proxy # cmd="cat $HOME/.globus/pp.txt | grid-proxy-init -pwstdin -q" cmd="cat /data/DBSDataDiscovery/COMP/DBS/Web/DataDiscovery/pp.txt | grid-proxy-init -cert /data/vk/cert/usercert.pem -key /data/vk/cert/userkey.pem -pwstdin -q" os.system(cmd) file = open('dls.all.tmp','w') for dbsInst in DBSInst.DBS_DLS_INST.keys(): iface="" try: url,dlsType,endpoint = DBSInst.DBS_DLS_INST[dbsInst] if dlsType=='DLS_TYPE_DLI': dlsType='DLS_TYPE_LFC' iface = dlsClient.getDlsApi(dlsType,endpoint) #print dbsInst,dlsType,endpoint,iface locList = iface.getAllLocations(session = True)
optManager = DBSOptionParser() (opts, args) = optManager.getOpt() ddConfig = DBSDDConfig() iface = ddConfig.iface() if opts.iface: iface = opts.iface if iface == "sqlalchemy": helper = DDHelper.DDHelper(iface=iface) else: helper = DBSHelper.DBSHelper(iface=iface) if opts.quiet: helper.setQuiet() if opts.dbsInst: if not DBSInst.DBS_DLS_INST.has_key(opts.dbsInst): print "Wrong DBS instances '%s'" % opts.dbsInst DBSUtil.printListElements(DBSInst.DBS_DLS_INST.keys(), "Known DBS instances") sys.exit(1) for dbsInst in DBSInst.DBS_DLS_INST.keys(): if opts.dbsInst: if dbsInst != opts.dbsInst: continue try: fileName = helper.initJSDict(dbsInst) except: printExcept() raise "Fail to generate JS dictionary for dbs instance", dbsInst try: if os.path.isfile(fileName) and os.stat(fileName)[stat.ST_SIZE] > 0: os.rename(fileName, string.replace(fileName, ".tmp", "")) except: printExcept()