test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cmsScimarkStop.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 #Script to
3 #1-check for cmsScimarkLaunch (infinite loop) scripts
4 #2-kill them
5 #3-report their results using cmsScimarkParser.py
6 
7 import subprocess,os,sys
8 
9 def main():
10  #Use ps -ef to look for cmsScimarkLaunch processes
11  ps_stdouterr=subprocess.Popen("ps -efww|grep cmsScimarkLaunch|grep -v grep|grep -v 'sh -c'",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
12  if ps_stdouterr:
13  ps_lines=ps_stdouterr.readlines()
14  #print ps_lines
15  if ps_lines:
16  for line in ps_lines:
17  tokens=line.split()
18  #Look up the PID
19  PID=tokens[1]
20  #Look up the cpu core
21  core=tokens[9]
22  print "Found process:\n%s"%line[:-1] #to eliminate the extra \n
23  #Kill the PID
24  print "Killing process with PID %s"%PID
25  kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
26  print kill_stdouterr
27  #Harvest the cmsScimark scores
28  #Look for the cmsScimark log:
29  if os.path.exists("cmsScimark_%s.log"%core):
30  #Create the results dir
31  mkdir_stdouterr=subprocess.Popen("mkdir cmsScimarkResults_cpu%s"%core,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
32  print mkdir_stdouterr
33  #Execute the harvesting scrip cmsScimarkParser.py (it is in the release)
34  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()
35  print harvest_stdouterr
36  else:
37  print "No cmsScimark_%s.log file was found for cpu%s, log might be in another directory!"%(core,core)
38  else:
39  print "No cmsScimarkLaunch processes found in the ps -ef output"
40  return 0
41 
42 if __name__ == "__main__":
43  sys.exit(main())
Definition: main.py:1