def findVmPeaks(setup): """ Find the VmPeak values """ vmPeakMax = 0 vmPeakMean = 0 RSSMean = 0 # matched_lines = grep(["Py\:PerfMonSvc\s*INFO\s*VmPeak:\s*[0-9]"], stdout_filename) # pattern = "([0-9]+)" # # now extract the digits from the found lines # N = 0 # vmPeaks = 0 # for line in matched_lines: # _vmPeak = re.search(pattern, line) # if _vmPeak: # N += 1 # vmPeak = _vmPeak.group(1) # if vmPeak > vmPeakMax: # vmPeakMax = vmPeak # vmPeaks += vmPeak # use the VmPeak script to get all values cmd = "%s python VmPeak.py >Pilot_VmPeak.txt" % (setup) try: ec, output = timedCommand(cmd, timeout=getProperTimeout(setup)) except Exception, e: tolog("!!WARNING!!1111!! Failed to execute VmPeak script: %s" % (e))
def executeBenchmark(self): """ Interface method for benchmark test """ # Use this method to interface with benchmark code # The method should return a dictionary containing the results of the test dictionary = {} cmd = "/afs/cern.ch/user/w/walkerr/public/kflops.sh" timeout = 120 tolog("Executing benchmark test: %s" % (cmd)) exitcode, output = timedCommand(cmd, timeout=timeout) if exitcode != 0: tolog("!!WARNING!!3434!! Encountered a problem with benchmark test: %s" % (output)) else: tolog("Benchmark finished") filename = "kflops.json" if not os.path.exists(filename): tolog("!!WARNING!!3435!! Benchmark did not produce expected output file: %s" % (filename)) else: tolog("Parsing benchmark output file: %s" % (filename)) dictionary = getJSONDictionary(filename) if dictionary == {}: tolog("!!WARNING!!3436!! Empty benchmark dictionary - nothing to report") return dictionary
def executeBenchmark(self): """ Interface method for benchmark test """ # Use this method to interface with benchmark code # The method should return a dictionary containing the results of the test dictionary = {} cmd = "export BMK_ROOTDIR='/cvmfs/atlas.cern.ch/repo/benchmarks/cern/current;" cmd += "$BMK_ROOTDIR/cern-benchmark --benchmarks=\"fastBmk\" --queue_host=dashb-test-mb.cern.ch --queue_port=61113 --username=vmspecprod --topic=/topic/vm.spec --cloud=cloud-name --vo=ATLAS" timeout = 120 tolog("Executing benchmark test: %s" % (cmd)) exitcode, output = timedCommand(cmd, timeout=timeout) if exitcode != 0: tolog("!!WARNING!!3434!! Encountered a problem with benchmark test: %s" % (output)) else: tolog("Benchmark finished") filename = "kflops.json" if not os.path.exists(filename): tolog("!!WARNING!!3435!! Benchmark did not produce expected output file: %s" % (filename)) else: tolog("Parsing benchmark output file: %s" % (filename)) dictionary = getJSONDictionary(filename) if dictionary == {}: tolog("!!WARNING!!3436!! Empty benchmark dictionary - nothing to report") return dictionary
def executeBenchmark(self): """ Interface method for benchmark test """ # Use this method to interface with benchmark code # The method should return a dictionary containing the results of the test dictionary = {} cmd = "/afs/cern.ch/user/w/walkerr/public/kflops.sh" timeout = 120 tolog("Executing benchmark test: %s" % (cmd)) exitcode, output = timedCommand(cmd, timeout=timeout) if exitcode != 0: tolog( "!!WARNING!!3434!! Encountered a problem with benchmark test: %s" % (output)) else: tolog("Benchmark finished") filename = "kflops.json" if not os.path.exists(filename): tolog( "!!WARNING!!3435!! Benchmark did not produce expected output file: %s" % (filename)) else: tolog("Parsing benchmark output file: %s" % (filename)) dictionary = getJSONDictionary(filename) if dictionary == {}: tolog( "!!WARNING!!3436!! Empty benchmark dictionary - nothing to report" ) return dictionary
def dumpStackTrace(pid): """ run the stack trace command """ # make sure that the process is not in a zombie state if not isZombie(pid): pUtil.tolog("Running stack trace command on pid=%d:" % (pid)) cmd = "pstack %d" % (pid) timeout = 60 exitcode, output = pUtil.timedCommand(cmd, timeout=timeout) pUtil.tolog(output or "(pstack returned empty string)") else: pUtil.tolog("Skipping pstack dump for zombie process")
def NOTUSEDgetUtilityCommand(self, **argdict): """ Prepare a utility command string """ # This method can be used to prepare a setup string for an optional utility tool, e.g. a memory monitor, # that will be executed by the pilot in parallel with the payload. # The pilot will look for an output JSON file (summary.json) and will extract pre-determined fields # from it and report them with the job updates. Currently the pilot expects to find fields related # to memory information. pid = argdict.get("pid", 0) release = argdict.get("release", "") homePackage = argdict.get("homePackage", "") cmtconfig = argdict.get("cmtconfig", "") summary = self.getUtilityJSONFilename() job_command = argdict.get("job_command", "") trf = argdict.get("trf", 0) interval = 60 # Get the setup path for the job command (everything up until the trf name) setup_path = self.getSetupPath(job_command, trf) default_release = "20.1.5" default_patch_release = "20.1.5.2" # "20.1.4.1" default_cmtconfig = "x86_64-slc6-gcc48-opt" default_swbase = "%s/atlas.cern.ch/repo/sw/software" % (self.getCVMFSPath()) cacheVer = homePackage.split("/")[-1] # could anything be extracted? if homePackage == cacheVer or cmtconfig == "": # (no) # This means there is no patched release available, ie. we need to use the fallback useDefault = True cacheVer = "" else: useDefault = False tolog("setup_path=%s" % setup_path) tolog("release=%s" % release) tolog("default_release=%s" % default_release) tolog("cacheVer=%s" % cacheVer) tolog("default_patch_release=%s" % default_patch_release) tolog("cmtconfig=%s" % cmtconfig) tolog("default_cmtconfig=%s" % default_cmtconfig) default_setup = self.updateSetupPathWithReleaseAndCmtconfig( setup_path, release, default_release, cacheVer, default_patch_release, cmtconfig, default_cmtconfig ) tolog("default_setup=%s" % default_setup) # Construct the name of the output file using the summary variable if summary.endswith(".json"): output = summary.replace(".json", ".txt") else: output = summary + ".txt" if useDefault: tolog( "Will use default (fallback) setup for MemoryMonitor since patched release number is needed for the setup, and none is available" ) cmd = default_setup else: # Get the standard setup standard_setup = setup_path _cmd = standard_setup + " which MemoryMonitor" # Can the MemoryMonitor be found? try: ec, output = timedCommand(_cmd, timeout=60) except Exception, e: tolog( "!!WARNING!!3434!! Failed to locate MemoryMonitor: will use default (for patch release %s): %s" % (default_patch_release, e) ) cmd = default_setup else:
def NOTUSEDgetUtilityCommand(self, **argdict): """ Prepare a utility command string """ # This method can be used to prepare a setup string for an optional utility tool, e.g. a memory monitor, # that will be executed by the pilot in parallel with the payload. # The pilot will look for an output JSON file (summary.json) and will extract pre-determined fields # from it and report them with the job updates. Currently the pilot expects to find fields related # to memory information. pid = argdict.get('pid', 0) release = argdict.get('release', '') homePackage = argdict.get('homePackage', '') cmtconfig = argdict.get('cmtconfig', '') summary = self.getUtilityJSONFilename() job_command = argdict.get('job_command', '') trf = argdict.get('trf', 0) interval = 60 # Get the setup path for the job command (everything up until the trf name) setup_path = self.getSetupPath(job_command, trf) default_release = "20.1.5" default_patch_release = "20.1.5.2" #"20.1.4.1" default_cmtconfig = "x86_64-slc6-gcc48-opt" default_swbase = "%s/atlas.cern.ch/repo/sw/software" % ( self.getCVMFSPath()) cacheVer = homePackage.split('/')[-1] # could anything be extracted? if homePackage == cacheVer or cmtconfig == "": # (no) # This means there is no patched release available, ie. we need to use the fallback useDefault = True cacheVer = "" else: useDefault = False tolog("setup_path=%s" % setup_path) tolog("release=%s" % release) tolog("default_release=%s" % default_release) tolog("cacheVer=%s" % cacheVer) tolog("default_patch_release=%s" % default_patch_release) tolog("cmtconfig=%s" % cmtconfig) tolog("default_cmtconfig=%s" % default_cmtconfig) default_setup = self.updateSetupPathWithReleaseAndCmtconfig( setup_path, release, default_release, cacheVer, default_patch_release, cmtconfig, default_cmtconfig) tolog("default_setup=%s" % default_setup) # Construct the name of the output file using the summary variable if summary.endswith('.json'): output = summary.replace('.json', '.txt') else: output = summary + '.txt' if useDefault: tolog( "Will use default (fallback) setup for MemoryMonitor since patched release number is needed for the setup, and none is available" ) cmd = default_setup else: # Get the standard setup standard_setup = setup_path _cmd = standard_setup + " which MemoryMonitor" # Can the MemoryMonitor be found? try: ec, output = timedCommand(_cmd, timeout=60) except Exception, e: tolog( "!!WARNING!!3434!! Failed to locate MemoryMonitor: will use default (for patch release %s): %s" % (default_patch_release, e)) cmd = default_setup else: