def getGPFSversion(self): if self.versionCommand != "": if self.devices != []: d = self.devices[0] c = self.versionCommand.replace("$device",d.name) command = c.split()[0] args = "" for a in c.split()[1:]: args += "%s " % a (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get file system version with command: %s %s \n" % (command, args) return if command.find("mmlsfs") >= 0: self.version = out.split("\n")[2].split()[1] else: if os.path.isfile("/usr/lpp/mmfs/bin/mmlsfs"): command = "/usr/lpp/mmfs/bin/mmlsfs" else: (out,err,ret) = my_exec2("which","mmlsfs") command = out if ret != 0: print "WARNING: could not locate mmlsfs command to get file system version information." return if self.devices != []: d = self.devices[0] args = "%s -V" % d.name (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get file system version with command: %s %s \n" % (command, args) return self.version = out.split("\n")[2].split()[1]
def getGPFSversion(self): if self.versionCommand != "": if self.devices != []: d = self.devices[0] c = self.versionCommand.replace("$device", d.name) command = c.split()[0] args = "" for a in c.split()[1:]: args += "%s " % a (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get file system version with command: %s %s \n" % ( command, args) return if command.find("mmlsfs") >= 0: self.version = out.split("\n")[2].split()[1] else: if os.path.isfile("/usr/lpp/mmfs/bin/mmlsfs"): command = "/usr/lpp/mmfs/bin/mmlsfs" else: (out, err, ret) = my_exec2("which", "mmlsfs") command = out if ret != 0: print "WARNING: could not locate mmlsfs command to get file system version information." return if self.devices != []: d = self.devices[0] args = "%s -V" % d.name (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get file system version with command: %s %s \n" % ( command, args) return self.version = out.split("\n")[2].split()[1]
def getMountPoint(self,OS): (out,err,ret) = my_exec2("which","df") command = out if ret != 0: print "WARNING: could not locate df command to get device mount point for %s" % self.name return if OS == "Linux": args = "-Ph %s" % self.deviceName elif OS == "AIX": args = "-Pg %s" % self.deviceName (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get device mount point with command: %s %s \n" % (command, args) return # Filesystem Size Used Avail Use% Mounted on self.mountPoint = out.split("\n")[1].split()[5]
def getMountPoint(self, OS): (out, err, ret) = my_exec2("which", "df") command = out if ret != 0: print "WARNING: could not locate df command to get device mount point for %s" % self.name return if OS == "Linux": args = "-Ph %s" % self.deviceName elif OS == "AIX": args = "-Pg %s" % self.deviceName (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get device mount point with command: %s %s \n" % ( command, args) return # Filesystem Size Used Avail Use% Mounted on self.mountPoint = out.split("\n")[1].split()[5]
def getLCRMqueueContents(self): if self.runMachine != "": args = "-m %s -o jid,name,user,runtime,status,exehost " % self.runMachine (out, err, ret) = my_exec2("pstat", args) print err if ret == 0: lines = out.split("\n") for line in lines[1:]: # chop off header line self.queueContents.append(line)
def attribFuncReq(self): if os.path.isfile("/usr/bin/vstat"): return 0 else: (out,err,ret) = my_exec2("vstat","") if ret == 0: return 0 else: return 1
def getLCRMqueueContents(self): if self.runMachine != "": args = "-m %s -o jid,name,user,runtime,status,exehost " % self.runMachine (out,err, ret) = my_exec2("pstat",args) print err if ret == 0: lines = out.split("\n") for line in lines[1:]: # chop off header line self.queueContents.append(line)
def attribFunc(self,resName=""): try: (out,err, ret) = my_exec2("vstat","") attribValue = None lines = out.split("\n") for line in lines: if line.strip().startswith("fw_ver"): avList = line.split("=") attribValue = avList[1] return attribValue except IOError: pass
def getLustreVersion(self): if not self.versionCommand : # no command supplied test = os.path.isfile("/proc/fs/lustre/version") if test: command = "cat /proc/fs/lustre/version" (out,err,ret) = my_exec2(command,"") if ret != 0: print "WARNING: could not get file system version with command: %s \n" % command return self.version = out.strip() else: # they supplied a command they want us to use parts = self.versionCommand.split(None,1) # split into cmmand and args command = parts[0] if len(parts) > 1: args = parts[1] else: args = [] (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get file system version with command: %s %s" % (command,args) return self.version = out
def getSizeAvailUsage(self, OS): (out,err,ret) = my_exec2("which","df") if ret != 0: print "WARNING: can't locate df to get device size and usage information for %s" % self.name return command = out if OS == "Linux": args = "-Ph %s" % self.deviceName elif OS == "AIX": args = "-Pg %s" % self.deviceName (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get device size and usage with command: %s %s \n" % (command, args) return self.size = out.split("\n")[1].split()[1] self.used = out.split("\n")[1].split()[2] self.avail = out.split("\n")[1].split()[3] # for AIX, we add on a G, because we requested data in units of GB if OS == "AIX": self.size += "G" self.used += "G" self.avail += "G" self.usedPercent = out.split("\n")[1].split()[4]
def getSizeAvailUsage(self, OS): (out, err, ret) = my_exec2("which", "df") if ret != 0: print "WARNING: can't locate df to get device size and usage information for %s" % self.name return command = out if OS == "Linux": args = "-Ph %s" % self.deviceName elif OS == "AIX": args = "-Pg %s" % self.deviceName (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get device size and usage with command: %s %s \n" % ( command, args) return self.size = out.split("\n")[1].split()[1] self.used = out.split("\n")[1].split()[2] self.avail = out.split("\n")[1].split()[3] # for AIX, we add on a G, because we requested data in units of GB if OS == "AIX": self.size += "G" self.used += "G" self.avail += "G" self.usedPercent = out.split("\n")[1].split()[4]
def getLustreVersion(self): if not self.versionCommand: # no command supplied test = os.path.isfile("/proc/fs/lustre/version") if test: command = "cat /proc/fs/lustre/version" (out, err, ret) = my_exec2(command, "") if ret != 0: print "WARNING: could not get file system version with command: %s \n" % command return self.version = out.strip() else: # they supplied a command they want us to use parts = self.versionCommand.split(None, 1) # split into cmmand and args command = parts[0] if len(parts) > 1: args = parts[1] else: args = [] (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get file system version with command: %s %s" % ( command, args) return self.version = out
def getMPIRUNversion(self): # this works with openMPI, mpich2 doesn't seem to have a version flag # so we don't get a version for it. (out, err, ret) = my_exec2("mpirun", "--version") if ret == 0: # open mpi outputs version info to stderr if out == "": lines = err.split("\n") else: lines = out.split("\n") self.launcherVersion = "" for line in lines: if self.launcherVersion != "": self.launcherVersion += " ;%s" % line else: self.launcherVersion += "%s" % line
def parse_cpuinfo(self): if self.OS == "": self.OS = os.uname()[0] if self.OS.upper() == "LINUX": f = open('/proc/cpuinfo', 'r') lines = f.readlines() count = 0 for line in lines: if line.startswith("processor"): count += 1 return count elif self.OS.upper == "AIX": (out,err,ret) = my_exec2("lsdev -c processor | grep -c proc") if ret != 0: return -1 return out.strip()
def getMPIRUNversion(self): # this works with openMPI, mpich2 doesn't seem to have a version flag # so we don't get a version for it. (out,err,ret) = my_exec2("mpirun","--version") if ret == 0: # open mpi outputs version info to stderr if out == "": lines = err.split("\n") else: lines = out.split("\n") self.launcherVersion = "" for line in lines: if self.launcherVersion != "": self.launcherVersion += " ;%s" % line else: self.launcherVersion += "%s" % line
def parse_cpuinfo(self): if self.OS == "": self.OS = os.uname()[0] if self.OS.upper() == "LINUX": f = open('/proc/cpuinfo', 'r') lines = f.readlines() count = 0 for line in lines: if line.startswith("processor"): count += 1 return count elif self.OS.upper == "AIX": (out, err, ret) = my_exec2("lsdev -c processor | grep -c proc") if ret != 0: return -1 return out.strip()
def getDynamicLibs(Executables): """Gathers the libraries loaded by executables with ldd, gets basic information about the libraries, and returns a list of libraries """ #gather libs from ldd output dynamic_libraries = [] for exe in Executables: # in future, need to parse the batch script file to make sure # that any env vars that are set there are set here before we # call ldd (search for export, setenv, source, ...) # and get the right dynamic libs (output,stderr, retval) = my_exec2("ldd", exe) if (retval != 0) : print "\nCannot run ldd on " + exe + "!! No library information obtained !!" print output return [] lines = output.split("\n") for line in lines: newLib = library() if (globals()["OS_name"] == "AIX"): #format: /full/path/to/lib/libname.a(objfilename.o) exename = exe.split('/') exename.reverse() #get just the exe name words = line.split('(') #split at the objfilename libname = words[0].split('/') #get just the lib name libname.reverse() if(exename[0] != libname[0]): #don't put the exe in the libs list newLib.name = libname[0] newLib.fullname = words[0] #full path and name #In AIX land there are libs that don't end in .a and don't #have member objs #check to see if this is one of those if (libname[0].find(".a") != -1): newLib.memberObject = words[1].rstrip(')') else: continue #skip the exe line else: #assume if not AIX then it's Linux for now #format: libname => /full/path/to/lib/libname (address) if line.startswith("linux-gate.so.1"): # skip non-existant virtual library for linux 2.6 continue words = line.split() #is there path info in libname? if (words[0].find("/") != -1): w = words[0].split("/") #extract out lib name w.reverse() newLib.name = w[0] newLib.fullname = words[0] else: newLib.name = words[0] newLib.fullname = words[2].strip() (retval,stat) = statFile(newLib.fullname) if (retval == 0): newLib.size = str(stat.size) newLib.timestamp = str(stat.mtime) newLib.version = "" #TODO newLib.type = getLibraryType(newLib.name) newLib.dynamic = "True" dynamic_libraries.insert(0,newLib) else: print 'Error: could not stat ' + newLib.fullname return dynamic_libraries
def getDynamicLibs(Executables): """Gathers the libraries loaded by executables with ldd, gets basic information about the libraries, and returns a list of libraries """ #gather libs from ldd output dynamic_libraries = [] for exe in Executables: # in future, need to parse the batch script file to make sure # that any env vars that are set there are set here before we # call ldd (search for export, setenv, source, ...) # and get the right dynamic libs (output, stderr, retval) = my_exec2("ldd", exe) if (retval != 0): print "\nCannot run ldd on " + exe + "!! No library information obtained !!" print output return [] lines = output.split("\n") for line in lines: newLib = library() if (globals()["OS_name"] == "AIX"): #format: /full/path/to/lib/libname.a(objfilename.o) exename = exe.split('/') exename.reverse() #get just the exe name words = line.split('(') #split at the objfilename libname = words[0].split('/') #get just the lib name libname.reverse() if (exename[0] != libname[0]): #don't put the exe in the libs list newLib.name = libname[0] newLib.fullname = words[0] #full path and name #In AIX land there are libs that don't end in .a and don't #have member objs #check to see if this is one of those if (libname[0].find(".a") != -1): newLib.memberObject = words[1].rstrip(')') else: continue #skip the exe line else: #assume if not AIX then it's Linux for now #format: libname => /full/path/to/lib/libname (address) if line.startswith("linux-gate.so.1"): # skip non-existant virtual library for linux 2.6 continue words = line.split() #is there path info in libname? if (words[0].find("/") != -1): w = words[0].split("/") #extract out lib name w.reverse() newLib.name = w[0] newLib.fullname = words[0] else: newLib.name = words[0] newLib.fullname = words[2].strip() (retval, stat) = statFile(newLib.fullname) if (retval == 0): newLib.size = str(stat.size) newLib.timestamp = str(stat.mtime) newLib.version = "" #TODO newLib.type = getLibraryType(newLib.name) newLib.dynamic = "True" dynamic_libraries.insert(0, newLib) else: print 'Error: could not stat ' + newLib.fullname return dynamic_libraries
def getData(exename, launcher, path=None, batchFile = "", \ inputDecks=[], usesMPI=False, \ usesOpenMP=False, usesPthreads=False, appname=None, format="old",CNLfixUp=False, ptDataDir="",exportEnvAtLaunch=False): uname_res = os.uname() run_OS_name = uname_res[0] run_OS_release_type = uname_res[2] run_OS_release_version = uname_res[3] globals()["OS_name"] = run_OS_name #what user is running this command userName = os.getenv('USER') # things we are expecting to get from parsing the launch command # or batch file: # machine name # number of processes, number of threads, processes per node, # partition job run on sub = Submission() okay = sub.getInfo(launcher,batchFile) if not okay: print "parsing of submission information failed" sys.exit(0) run_machine = sub.getRunMachine() numberOfProcesses = sub.getNumberOfProcesses() processesPerNode = sub.getProcessesPerNode() numberOfThreads = sub.getNumberOfThreads() numberOfNodes = sub.getNumberOfNodes() if numberOfThreads == -1 and usesOpenMP == True: # default OMP_NUM_THREADS is number of cpus per node numberOfThreads = sub.getCpusPerNode() elif numberOfThreads == -1: numberOfThreads = 1 #print "runmachine="+str(run_machine)+ " usesMPI="+str(usesMPI) +" usesOpenMP="+ str(usesOpenMP) + " usesPthreads="+ str(usesPthreads) +" numberOfProcesses=" +str(numberOfProcesses) + " numberOfThreads="+ str(numberOfThreads) #print "runmachine="+str(run_machine) #print " usesMPI="+str(usesMPI) #print " usesOpenMP="+ str(usesOpenMP) #print " usesPthreads="+ str(usesPthreads) #print " numberOfProcesses=" +str(numberOfProcesses) #print " numberOfThreads="+ str(numberOfThreads) # Grab env vars to put in DB => runEnv (result, output) = commands.getstatusoutput('env') if (result != 0): print 'environment (\'env\') command failed with error: ' + str(result) print output sys.exit(2) # for simplicity, runEnvVars is a string of (envVar=value) separated by # '@@@' e.g. envVar1=value1@@@envVar2=value2@@@envVar3=value3 runEnvVars = output.replace("\n","@@@") page_size = os.sysconf('SC_PAGESIZE') #TODO double check this size has consistent units across platforms. if(path): dynLibs = getDynamicLibs([path]) else: dynLibs = getDynamicLibs([exename]) # this gets file system information fs = fsInfo() fs.getInfo() # if we're running on a Cray XT machine, the compute nodes may be running # compute node linux, while the login nodes are running regular linux # we want to add some commands to the batch file to get some data # directly from the compute nodes if(CNLfixUp): tmpBatch = "%s.ptBatch" % batchFile cmds = "" cmds += "aprun -n 1 uname -s > %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 uname -r >> %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 uname -v >> %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 env > %s/out.env ;" % ptDataDir cmds += "ptCNLfix.py %s" % ptDataDir #sedcmd = "'s/PERFTRACK_CMDS/%s/g' %s > %s" % (cmds,batchFile,tmpBatch) my_exec2("cp %s %s" % (batchFile,tmpBatch), "") my_exec2('echo "%s" >>' % cmds, tmpBatch) batchFile = tmpBatch # get the current date and time in ISO format launchTime = string.split(str(datetime.datetime.isoformat( \ datetime.datetime.now())), '.')[0] # get input deck information # TODO fix this so that we can get the relevant information out from # the input decks - somehow. perhaps provide an interface to enter # name, value pairs for important input information, such as x=192 or # weather=cloudy # for now, we are just recording the names of the files and their # modification date. # oh, and we expect the input files to exist in the current working # directory , or be given a complete path to the file iDecks= getInputDecks(inputDecks) # launch the job if launcher == "lcrm": (out, err, retval) = my_exec2("psub", batchFile) print out print err elif launcher == "pbs": #print "NOT LAUNCHING" if (CNLfixUp or exportEnvAtLaunch): (out, err, retval) = my_exec2("qsub -V", batchFile) else: (out, err, retval) = my_exec2("qsub", batchFile) print out print err elif launcher == "mpirun": mpirunArgs = sub.getLauncherArgs() (out, err, retval) = my_exec2("mpirun", mpirunArgs) print out print err # output data if format == "PERIxml": filename = "perftrack_run_" + exename + "_" \ + launchTime.replace(" ","") + "." + run_machine+ ".xml" if path: exeName = path else: exeName = exename printInPERIformat(filename,launchTime, userName, appname, exeName,run_machine, run_OS_name, run_OS_release_version, run_OS_release_type, runEnvVars, page_size, str(numberOfNodes), str(numberOfProcesses), str(processesPerNode), str(numberOfThreads), str(usesMPI), str(usesOpenMP), str(usesPthreads), sub, fs, dynLibs, iDecks ) return filename if(exename == None): print "no exeName specified. Error" sys.exit(1) filename = "perftrack_run_" + exename + "_" + launchTime.replace(" ","") \ + "." + run_machine+ ".txt" file = open(filename,'w') file.write("RunDataBegin\n") file.write("LaunchDateTime=" + launchTime +"\n") file.write("UserName="******"\n") if appname: file.write("ApplicationName=" + appname + "\n") if path: file.write("ExecutableName=" + path + "\n") else: file.write("ExecutableName=" + exename + "\n") file.write("RunMachine=" + run_machine + "\n") file.write("RunOSName=" + run_OS_name + "\n") file.write("RunOSReleaseVersion=" + run_OS_release_version + "\n" ) file.write("RunOSReleaseType=" + run_OS_release_type + "\n") file.write("RunEnv="+ runEnvVars + "\n") file.write("PageSize=" + str(page_size) + "\n") if numberOfNodes != -1: file.write("NumberOfNodes=" + str(numberOfNodes) + "\n") if numberOfProcesses != -1: file.write("NumberOfProcesses=" + str(numberOfProcesses) + "\n") if processesPerNode != -1: # sometimes we can't figure it out file.write("ProcessesPerNode=" + str(processesPerNode) + "\n") if (usesOpenMP or usesPthreads) and numberOfThreads != -1: file.write("ThreadsPerProcess=" + str(numberOfThreads) + "\n") file.write("UsesMPI=" + str(usesMPI) +"\n") file.write("UsesOpenMP=" + str(usesOpenMP) + "\n") file.write("UsesPthreads=" + str(usesPthreads) +"\n") file.write(sub.printData()) file.write(fs.printData()) for l in dynLibs: file.write(l.printData()) for (f,mt) in iDecks: file.write("InputDeckBegin\n") file.write("InputDeckName=" + f + "\n") file.write("InputDeckModTime=" + mt + "\n") file.write("InputDeckEnd\n") file.write("RunDataEnd\n") file.close() return filename
def getfsInfo(self): if self.getOS() == "Linux": (out,err,ret) = my_exec2("which","df") command = out if ret != 0: print "WARNING: could not locate df command to get file system info" print "attempting to retrieve file system info from $HOME/.ptconfig..." self.getFsInfoFromFile() return args = "-PTh" (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get filesystem info with command: %s %s" % (command,args) return lines = out.splitlines()[1:] # skip first line fses = {} for l in lines: #print l name = l.split()[1] if name in fses: fs = fses[name] else: fs = filesystem() fs.name = name fses[name] = fs parts = l.split() device = parts[0] size = parts[2] used = parts[3] avail = parts[4] usedPercent = parts[5] mountPoint = parts[6] #print "adding device: %s %s %s" % (device, mountPoint,size) fs.addDevice(device,mountPoint,size,used,avail,usedPercent) self.filesystems = fses.values() elif self.getOS() == "AIX": if not os.path.isfile("/etc/filesystems"): print "WARNING: could not get filesystem info from /etc/filesystems" return command = "cat" args = "/etc/filesystems" (out,err,ret) = my_exec2(command,args) if ret != 0: print "WARNING: could not get filesystem info with command: %s %s" % (command,args) return fses = {} lines = out.splitlines() i = 0 while i < len(lines)-1: l = lines[i].strip() #print "line:%s, %s" % (i,l) # skip if comments,blanks if l.startswith("*") or l == "": i += 1 continue if l.endswith(":"): # that's a new device to parse mountPoint = l.rstrip(":").strip() i += 1 while i < len(lines)-1: l = lines[i].strip() #print "line:%s, %s" % (i,l) # see if we're done with this one yet or not if l.endswith(":") or l == "": break if l.startswith("dev"): deviceName = l.split("=")[1].strip() elif l.startswith("vfs"): fsname = l.split("=")[1].strip() if fsname in fses: fs = fses[fsname] else: fs = filesystem() fs.name = fsname fses[fsname] = fs i += 1 fs.addDevice(deviceName,mountPoint,"","","","") self.filesystems = fses.values()
def getPBSqueueContents(self): (out, err, retval) = my_exec2("qstat","" ) if retval == 0: lines = out.split("\n") for line in lines[2:]: # chop off header lines self.queueContents.append(line)
def getPBSversion(self): args = "-Bf | awk '/pbs_version/ {print $3}'" (out, err, retval) = my_exec2("qstat", args) #print "pbs version said: " + out self.launcherVersion = out
def attribFuncReq(self): (out,err,ret) = my_exec2("vstat","") if ret == 0: return 0 else: return 1
def getPBSqueueContents(self): (out, err, retval) = my_exec2("qstat", "") if retval == 0: lines = out.split("\n") for line in lines[2:]: # chop off header lines self.queueContents.append(line)
def getData(exename, launcher, path=None, batchFile = "", \ inputDecks=[], usesMPI=False, \ usesOpenMP=False, usesPthreads=False, appname=None, format="old",CNLfixUp=False, ptDataDir="",exportEnvAtLaunch=False): uname_res = os.uname() run_OS_name = uname_res[0] run_OS_release_type = uname_res[2] run_OS_release_version = uname_res[3] globals()["OS_name"] = run_OS_name #what user is running this command userName = os.getenv('USER') # things we are expecting to get from parsing the launch command # or batch file: # machine name # number of processes, number of threads, processes per node, # partition job run on sub = Submission() okay = sub.getInfo(launcher, batchFile) if not okay: print "parsing of submission information failed" sys.exit(0) run_machine = sub.getRunMachine() numberOfProcesses = sub.getNumberOfProcesses() processesPerNode = sub.getProcessesPerNode() numberOfThreads = sub.getNumberOfThreads() numberOfNodes = sub.getNumberOfNodes() if numberOfThreads == -1 and usesOpenMP == True: # default OMP_NUM_THREADS is number of cpus per node numberOfThreads = sub.getCpusPerNode() elif numberOfThreads == -1: numberOfThreads = 1 #print "runmachine="+str(run_machine)+ " usesMPI="+str(usesMPI) +" usesOpenMP="+ str(usesOpenMP) + " usesPthreads="+ str(usesPthreads) +" numberOfProcesses=" +str(numberOfProcesses) + " numberOfThreads="+ str(numberOfThreads) #print "runmachine="+str(run_machine) #print " usesMPI="+str(usesMPI) #print " usesOpenMP="+ str(usesOpenMP) #print " usesPthreads="+ str(usesPthreads) #print " numberOfProcesses=" +str(numberOfProcesses) #print " numberOfThreads="+ str(numberOfThreads) # Grab env vars to put in DB => runEnv (result, output) = commands.getstatusoutput('env') if (result != 0): print 'environment (\'env\') command failed with error: ' + str(result) print output sys.exit(2) # for simplicity, runEnvVars is a string of (envVar=value) separated by # '@@@' e.g. envVar1=value1@@@envVar2=value2@@@envVar3=value3 runEnvVars = output.replace("\n", "@@@") page_size = os.sysconf( 'SC_PAGESIZE' ) #TODO double check this size has consistent units across platforms. if (path): dynLibs = getDynamicLibs([path]) else: dynLibs = getDynamicLibs([exename]) # this gets file system information fs = fsInfo() fs.getInfo() # if we're running on a Cray XT machine, the compute nodes may be running # compute node linux, while the login nodes are running regular linux # we want to add some commands to the batch file to get some data # directly from the compute nodes if (CNLfixUp): tmpBatch = "%s.ptBatch" % batchFile cmds = "" cmds += "aprun -n 1 uname -s > %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 uname -r >> %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 uname -v >> %s/out.uname ;" % ptDataDir cmds += "aprun -n 1 env > %s/out.env ;" % ptDataDir cmds += "ptCNLfix.py %s" % ptDataDir #sedcmd = "'s/PERFTRACK_CMDS/%s/g' %s > %s" % (cmds,batchFile,tmpBatch) my_exec2("cp %s %s" % (batchFile, tmpBatch), "") my_exec2('echo "%s" >>' % cmds, tmpBatch) batchFile = tmpBatch # get the current date and time in ISO format launchTime = string.split(str(datetime.datetime.isoformat( \ datetime.datetime.now())), '.')[0] # get input deck information # TODO fix this so that we can get the relevant information out from # the input decks - somehow. perhaps provide an interface to enter # name, value pairs for important input information, such as x=192 or # weather=cloudy # for now, we are just recording the names of the files and their # modification date. # oh, and we expect the input files to exist in the current working # directory , or be given a complete path to the file iDecks = getInputDecks(inputDecks) # launch the job if launcher == "lcrm": (out, err, retval) = my_exec2("psub", batchFile) print out print err elif launcher == "pbs": #print "NOT LAUNCHING" if (CNLfixUp or exportEnvAtLaunch): (out, err, retval) = my_exec2("qsub -V", batchFile) else: (out, err, retval) = my_exec2("qsub", batchFile) print out print err elif launcher == "mpirun": mpirunArgs = sub.getLauncherArgs() (out, err, retval) = my_exec2("mpirun", mpirunArgs) print out print err # output data if format == "PERIxml": filename = "perftrack_run_" + exename + "_" \ + launchTime.replace(" ","") + "." + run_machine+ ".xml" if path: exeName = path else: exeName = exename printInPERIformat(filename, launchTime, userName, appname, exeName, run_machine, run_OS_name, run_OS_release_version, run_OS_release_type, runEnvVars, page_size, str(numberOfNodes), str(numberOfProcesses), str(processesPerNode), str(numberOfThreads), str(usesMPI), str(usesOpenMP), str(usesPthreads), sub, fs, dynLibs, iDecks) return filename if (exename == None): print "no exeName specified. Error" sys.exit(1) filename = "perftrack_run_" + exename + "_" + launchTime.replace(" ","") \ + "." + run_machine+ ".txt" file = open(filename, 'w') file.write("RunDataBegin\n") file.write("LaunchDateTime=" + launchTime + "\n") file.write("UserName="******"\n") if appname: file.write("ApplicationName=" + appname + "\n") if path: file.write("ExecutableName=" + path + "\n") else: file.write("ExecutableName=" + exename + "\n") file.write("RunMachine=" + run_machine + "\n") file.write("RunOSName=" + run_OS_name + "\n") file.write("RunOSReleaseVersion=" + run_OS_release_version + "\n") file.write("RunOSReleaseType=" + run_OS_release_type + "\n") file.write("RunEnv=" + runEnvVars + "\n") file.write("PageSize=" + str(page_size) + "\n") if numberOfNodes != -1: file.write("NumberOfNodes=" + str(numberOfNodes) + "\n") if numberOfProcesses != -1: file.write("NumberOfProcesses=" + str(numberOfProcesses) + "\n") if processesPerNode != -1: # sometimes we can't figure it out file.write("ProcessesPerNode=" + str(processesPerNode) + "\n") if (usesOpenMP or usesPthreads) and numberOfThreads != -1: file.write("ThreadsPerProcess=" + str(numberOfThreads) + "\n") file.write("UsesMPI=" + str(usesMPI) + "\n") file.write("UsesOpenMP=" + str(usesOpenMP) + "\n") file.write("UsesPthreads=" + str(usesPthreads) + "\n") file.write(sub.printData()) file.write(fs.printData()) for l in dynLibs: file.write(l.printData()) for (f, mt) in iDecks: file.write("InputDeckBegin\n") file.write("InputDeckName=" + f + "\n") file.write("InputDeckModTime=" + mt + "\n") file.write("InputDeckEnd\n") file.write("RunDataEnd\n") file.close() return filename
def getfsInfo(self): if self.getOS() == "Linux": (out, err, ret) = my_exec2("which", "df") command = out if ret != 0: print "WARNING: could not locate df command to get file system info" print "attempting to retrieve file system info from $HOME/.ptconfig..." self.getFsInfoFromFile() return args = "-PTh" (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get filesystem info with command: %s %s" % ( command, args) return lines = out.splitlines()[1:] # skip first line fses = {} for l in lines: #print l name = l.split()[1] if name in fses: fs = fses[name] else: fs = filesystem() fs.name = name fses[name] = fs parts = l.split() device = parts[0] size = parts[2] used = parts[3] avail = parts[4] usedPercent = parts[5] mountPoint = parts[6] #print "adding device: %s %s %s" % (device, mountPoint,size) fs.addDevice(device, mountPoint, size, used, avail, usedPercent) self.filesystems = fses.values() elif self.getOS() == "AIX": if not os.path.isfile("/etc/filesystems"): print "WARNING: could not get filesystem info from /etc/filesystems" return command = "cat" args = "/etc/filesystems" (out, err, ret) = my_exec2(command, args) if ret != 0: print "WARNING: could not get filesystem info with command: %s %s" % ( command, args) return fses = {} lines = out.splitlines() i = 0 while i < len(lines) - 1: l = lines[i].strip() #print "line:%s, %s" % (i,l) # skip if comments,blanks if l.startswith("*") or l == "": i += 1 continue if l.endswith(":"): # that's a new device to parse mountPoint = l.rstrip(":").strip() i += 1 while i < len(lines) - 1: l = lines[i].strip() #print "line:%s, %s" % (i,l) # see if we're done with this one yet or not if l.endswith(":") or l == "": break if l.startswith("dev"): deviceName = l.split("=")[1].strip() elif l.startswith("vfs"): fsname = l.split("=")[1].strip() if fsname in fses: fs = fses[fsname] else: fs = filesystem() fs.name = fsname fses[fsname] = fs i += 1 fs.addDevice(deviceName, mountPoint, "", "", "", "") self.filesystems = fses.values()