Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 import subprocess,os,sys
00008
00009 def main():
00010
00011 ps_stdouterr=subprocess.Popen("ps -efww|grep cmsScimarkLaunch|grep -v grep|grep -v 'sh -c'",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
00012 if ps_stdouterr:
00013 ps_lines=ps_stdouterr.readlines()
00014
00015 if ps_lines:
00016 for line in ps_lines:
00017 tokens=line.split()
00018
00019 PID=tokens[1]
00020
00021 core=tokens[9]
00022 print "Found process:\n%s"%line[:-1]
00023
00024 print "Killing process with PID %s"%PID
00025 kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
00026 print kill_stdouterr
00027
00028
00029 if os.path.exists("cmsScimark_%s.log"%core):
00030
00031 mkdir_stdouterr=subprocess.Popen("mkdir cmsScimarkResults_cpu%s"%core,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
00032 print mkdir_stdouterr
00033
00034 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()
00035 print harvest_stdouterr
00036 else:
00037 print "No cmsScimark_%s.log file was found for cpu%s, log might be in another directory!"%(core,core)
00038 else:
00039 print "No cmsScimarkLaunch processes found in the ps -ef output"
00040 return 0
00041
00042 if __name__ == "__main__":
00043 sys.exit(main())