Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-10 22:50:02

0001 #! /usr/bin/env python3
0002 #Script to
0003 #1-check for cmsScimarkLaunch (infinite loop) scripts
0004 #2-kill them
0005 #3-report their results using cmsScimarkParser.py
0006 
0007 from __future__ import print_function
0008 import subprocess,os,sys
0009 
0010 def main():
0011     #Use ps -ef to look for cmsScimarkLaunch processes
0012     ps_stdouterr=subprocess.Popen("ps -efww|grep cmsScimarkLaunch|grep -v grep|grep -v 'sh -c'",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
0013     if ps_stdouterr:
0014         ps_lines=ps_stdouterr.readlines()
0015         #print ps_lines
0016     if ps_lines:
0017         for line in ps_lines:
0018             tokens=line.split()
0019             #Look up the PID
0020             PID=tokens[1]
0021             #Look up the cpu core
0022             core=tokens[9]
0023             print("Found process:\n%s"%line[:-1]) #to eliminate the extra \n
0024             #Kill the PID
0025             print("Killing process with PID %s"%PID)
0026             kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() 
0027             print(kill_stdouterr)
0028             #Harvest the cmsScimark scores
0029             #Look for the cmsScimark log:
0030             if os.path.exists("cmsScimark_%s.log"%core): 
0031                 #Create the results dir
0032                 mkdir_stdouterr=subprocess.Popen("mkdir cmsScimarkResults_cpu%s"%core,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
0033                 print(mkdir_stdouterr)
0034                 #Execute the harvesting scrip cmsScimarkParser.py (it is in the release)
0035                 harvest_stdouterr=subprocess.Popen("cmsScimarkParser.py -i cmsScimark_%s.log -o cmsScimarkResults_cpu%s"%(core,core),shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
0036                 print(harvest_stdouterr)
0037             else:
0038                 print("No cmsScimark_%s.log file was found for cpu%s, log might be in another directory!"%(core,core))
0039     else:
0040         print("No cmsScimarkLaunch processes found in the ps -ef output")
0041     return 0
0042 
0043 if __name__ == "__main__":
0044     sys.exit(main())