CMS 3D CMS Logo

cmsScimarkStop.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
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 from __future__ import print_function
8 import subprocess,os,sys
9 
10 def main():
11  #Use ps -ef to look for cmsScimarkLaunch processes
12  ps_stdouterr=subprocess.Popen("ps -efww|grep cmsScimarkLaunch|grep -v grep|grep -v 'sh -c'",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
13  if ps_stdouterr:
14  ps_lines=ps_stdouterr.readlines()
15  #print ps_lines
16  if ps_lines:
17  for line in ps_lines:
18  tokens=line.split()
19  #Look up the PID
20  PID=tokens[1]
21  #Look up the cpu core
22  core=tokens[9]
23  print("Found process:\n%s"%line[:-1]) #to eliminate the extra \n
24  #Kill the PID
25  print("Killing process with PID %s"%PID)
26  kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
27  print(kill_stdouterr)
28  #Harvest the cmsScimark scores
29  #Look for the cmsScimark log:
30  if os.path.exists("cmsScimark_%s.log"%core):
31  #Create the results dir
32  mkdir_stdouterr=subprocess.Popen("mkdir cmsScimarkResults_cpu%s"%core,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
33  print(mkdir_stdouterr)
34  #Execute the harvesting scrip cmsScimarkParser.py (it is in the release)
35  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()
36  print(harvest_stdouterr)
37  else:
38  print("No cmsScimark_%s.log file was found for cpu%s, log might be in another directory!"%(core,core))
39  else:
40  print("No cmsScimarkLaunch processes found in the ps -ef output")
41  return 0
42 
43 if __name__ == "__main__":
44  sys.exit(main())
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Definition: main.py:1