CMS 3D CMS Logo

Functions

cmsScimarkStop Namespace Reference

Functions

def main

Function Documentation

def cmsScimarkStop::main ( )

Definition at line 9 of file cmsScimarkStop.py.

00010           :
00011     #Use ps -ef to look for cmsScimarkLaunch processes
00012     ps_stdouterr=subprocess.Popen("ps -efww|grep cmsScimarkLaunch|grep -v grep|grep -v 'sh -c'",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout
00013     if ps_stdouterr:
00014         ps_lines=ps_stdouterr.readlines()
00015         #print ps_lines
00016     if ps_lines:
00017         for line in ps_lines:
00018             tokens=line.split()
00019             #Look up the PID
00020             PID=tokens[1]
00021             #Look up the cpu core
00022             core=tokens[9]
00023             print "Found process:\n%s"%line[:-1] #to eliminate the extra \n
00024             #Kill the PID
00025             print "Killing process with PID %s"%PID
00026             kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read() 
00027             print kill_stdouterr
00028             #Harvest the cmsScimark scores
00029             #Look for the cmsScimark log:
00030             if os.path.exists("cmsScimark_%s.log"%core): 
00031                 #Create the results dir
00032                 mkdir_stdouterr=subprocess.Popen("mkdir cmsScimarkResults_cpu%s"%core,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
00033                 print mkdir_stdouterr
00034                 #Execute the harvesting scrip cmsScimarkParser.py (it is in the release)
00035                 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()
00036                 print harvest_stdouterr
00037             else:
00038                 print "No cmsScimark_%s.log file was found for cpu%s, log might be in another directory!"%(core,core)
00039     else:
00040         print "No cmsScimarkLaunch processes found in the ps -ef output"
00041     return 0