def run(self): currState = None try: line = self.stream.readline() while line: parsed = self.pRegex.match(line) if parsed: logger.debug("Detected item: %s" % line.strip()) if parsed.group(1) == 'state': currState = parsed.group(2).strip() elif parsed.group(1) == 'np': procNum = int(parsed.group(2).strip()) if not ('down' in currState or 'offline' in currState or 'unknown' in currState): self.totalCPU += procNum if currState == 'free': self.freeCPU += procNum elif parsed.group(1) == 'jobs': jobList = parsed.group(2).strip() if currState == 'free' and len(jobList) > 0: self.freeCPU -= jobList.count(',') + 1 line = self.stream.readline() except: logger.debug("Error parsing pbsnodes output", exc_info=True) self.errList.append(CommonUtils.errorMsgFromTrace())
def run(self): try: line = self.stream.readline() while line: tmptuple = line.strip().split(',') if len(tmptuple) == 2: gpu_uuid = tmptuple[0].strip() if not gpu_uuid in self.num_of_procs: self.num_of_procs[gpu_uuid] = 1 else: self.num_of_procs[gpu_uuid] += 1 line = self.stream.readline() except: logger.debug("Error parsing nvidia-smi output", exc_info=True) self.errList.append(CommonUtils.errorMsgFromTrace())
def run(self): currState = None currNode = None try: line = self.stream.readline() while line: parsed = self.pRegex.match(line) if parsed: logger.debug("Detected item: %s" % line.strip()) if parsed.group(1) == 'state': currState = parsed.group(2).strip() elif parsed.group(1) == 'np': procNum = int(parsed.group(2).strip()) if not ('down' in currState or 'offline' in currState or 'unknown' in currState): self.totalCPU += procNum if currState == 'free': self.freeCPU += procNum elif parsed.group(1) == 'jobs': jobList = parsed.group(2).strip() if currState == 'free' and len(jobList) > 0: self.freeCPU -= jobList.count(',') + 1 elif parsed.group(1) == 'gpu_status': gpuNodeInfo = dict() gpuNodeInfo['node_state'] = currState gpuNodeInfo['total_gpus'] = 0 gpuNodeInfo['free_gpus'] = 0 for gpuStats in self.gpuRegex.split( parsed.group(2).strip()): gpuStats = gpuStats.strip() if len(gpuStats) == 0: continue curr_gpu_use = 100 curr_mem_use = 100 for pStr in gpuStats.split(';'): res = self.pRegex.match(pStr) if res.group(1) == 'gpu_utilization': curr_gpu_use = int( re.match('\d+', res.group(2)).group(0)) elif res.group(1) == 'gpu_memory_utilization': curr_mem_use = int( re.match('\d+', res.group(2)).group(0)) if curr_gpu_use == 0 and curr_mem_use == 0: gpuNodeInfo['free_gpus'] += 1 gpuNodeInfo['total_gpus'] += 1 self.gpuTable[currNode] = gpuNodeInfo else: tmps = line.strip() if len(tmps): currNode = tmps line = self.stream.readline() except: logger.debug("Error parsing pbsnodes output", exc_info=True) self.errList.append(CommonUtils.errorMsgFromTrace())
def run(self): currState = None currNode = None try: line = self.stream.readline() while line: parsed = self.pRegex.match(line) if parsed: logger.debug("Detected item: %s" % line.strip()) if parsed.group(1) == 'state': currState = parsed.group(2).strip() elif parsed.group(1) == 'np': procNum = int(parsed.group(2).strip()) if not ('down' in currState or 'offline' in currState or 'unknown' in currState): self.totalCPU += procNum if currState == 'free': self.freeCPU += procNum elif parsed.group(1) == 'jobs': jobList = parsed.group(2).strip() if currState == 'free' and len(jobList) > 0: self.freeCPU -= jobList.count(',') + 1 elif parsed.group(1) == 'gpu_status': gpuNodeInfo = dict() gpuNodeInfo['node_state'] = currState gpuNodeInfo['total_gpus'] = 0 gpuNodeInfo['free_gpus'] = 0 for gpuStats in self.gpuRegex.split(parsed.group(2).strip()): gpuStats = gpuStats.strip() if len(gpuStats) == 0: continue curr_gpu_use = 100 curr_mem_use = 100 for pStr in gpuStats.split(';'): res = self.pRegex.match(pStr) if res.group(1) == 'gpu_utilization': curr_gpu_use = int(re.match('\d+', res.group(2)).group(0)) elif res.group(1) == 'gpu_memory_utilization': curr_mem_use = int(re.match('\d+', res.group(2)).group(0)) if curr_gpu_use == 0 and curr_mem_use ==0: gpuNodeInfo['free_gpus'] += 1 gpuNodeInfo['total_gpus'] += 1 self.gpuTable[currNode] = gpuNodeInfo else: tmps = line.strip() if len(tmps): currNode = tmps line = self.stream.readline() except: logger.debug("Error parsing pbsnodes output", exc_info=True) self.errList.append(CommonUtils.errorMsgFromTrace())