diff --git a/LSF-Script/node/node b/LSF-Script/node/node index c76fb96a1f6201d0162634ffd601c49290ae0262..a24f900720c83686f286a6998128658cf56b74b7 100644 --- a/LSF-Script/node/node +++ b/LSF-Script/node/node @@ -43,6 +43,10 @@ import re # "status": "", # "originStatus": "" # }] +def transferMem(mem): + if mem[-1:] == 'T': + return str(float(mem[:-1]) * 1024) + 'G' + return mem LSLOAD_CMD = 'source @SCHEDULER_PROFILE_PATH@;' \ 'timeout 10 lsload -w' @@ -86,7 +90,7 @@ for index in range(0, len(slotstr)): nodeArrayList = [] for nodearry in nodes: - output = {"nativeResources": {"loadResources": {"cpuFree": slots[nodearry['HOST_NAME']] if slots.keys().__contains__(nodearry['HOST_NAME']) else 0,"gpuFree": "","memFree": nodearry['mem'] if nodearry.keys().__contains__('mem') else None},"mCpu": "","mGpu": "","mem": ""}, + output = {"nativeResources": {"loadResources": {"cpuFree": slots[nodearry['HOST_NAME']] if slots.keys().__contains__(nodearry['HOST_NAME']) else 0,"gpuFree": "","memFree": transferMem(nodearry['mem']) if nodearry.keys().__contains__('mem') else None},"mCpu": "","mGpu": "","mem": ""}, "nodeName": nodearry['HOST_NAME'],"numaInfo": {"architecture": ""},"powerSavingStatus": "", "status": "","originStatus": ""} nodeArrayList.append(output) @@ -115,7 +119,7 @@ for hostinfo in nodeArrayList: for host in hosts: if host['HOST_NAME'] == hostinfo['nodeName']: hostinfo['nativeResources']['mCpu'] = host['ncpus'] - hostinfo['nativeResources']['mem'] = host['maxmem'] + hostinfo['nativeResources']['mem'] = transferMem(host['maxmem']) hostinfo['numaInfo']['architecture'] = host['type'] if (hostinfo['status'] == 'CLOSED' and hostinfo['nativeResources']['loadResources']['cpuFree'] == 0): hostinfo['nativeResources']['loadResources']['cpuFree'] = host['ncpus'] diff --git a/LSF-Script/node/nodeSample b/LSF-Script/node/nodeSample index ac1ac6768c9e4147520ef39f46efb50e083373dc..b765e07053224abc7478a68f5b378cc0957d633d 100644 --- a/LSF-Script/node/nodeSample +++ b/LSF-Script/node/nodeSample @@ -5,6 +5,13 @@ import json import os import time +def transferMemToMB(mem): + if mem[-1:] == 'T': + return int(float(mem[:-1]) * 1024 * 1024) + elif mem[-1:] == 'G': + return int(float(mem[:-1]) * 1024) + return int(float(mem[:-1])) + LSLOAD_CMD = 'source @SCHEDULER_PROFILE_PATH@;' \ 'timeout 10 lsload -l' @@ -78,8 +85,8 @@ for nodeinfo in nodes: nodeinfoTmp[key] = nodeinfo[key] memFreeTmp = None if nodeinfoTmp['mem'] != None: - memFreeTmp = int(float(nodeinfoTmp['mem'][:-1]) * 1024) if nodeinfoTmp['mem'][-1:] == 'G' else int( - float(nodeinfoTmp['mem'][:-1])) + # 0317修改:调用了转换方法 + memFreeTmp = transferMemToMB(nodeinfoTmp['mem']) output = { "cluster": "", "timeStampL": sampletime, @@ -93,9 +100,11 @@ for nodeinfo in nodes: "gpu": "", "gpuFree": None, "swap": "", - "swapFree": int(float(nodeinfoTmp['swp'][:-1]) * 1024) if nodeinfoTmp['swp'] != None else None, + # 0317修改:调用了转换方法 + "swapFree": transferMemToMB(nodeinfoTmp['swp']), "tmp": None, - "tmpFree": int(float(nodeinfoTmp['tmp'][:-1])) if nodeinfoTmp['tmp'] != None else None, + # 0317修改:调用了转换方法 + "tmpFree": transferMemToMB(nodeinfoTmp['tmp']), "cpuUtil": float(nodeinfoTmp['ut'][:-1]) / 100 if nodeinfoTmp['ut'] != None else None, "loadAverage": None, "ioRate": nodeinfoTmp['io'] if nodeinfoTmp['io'] != '-' else None, @@ -127,8 +136,8 @@ for hostinfo in nodeArrayList: for host in hosts: if host['HOST_NAME'] == hostinfo['hostName']: hostinfo['core'] = None if host['ncpus'] == '-' else host['ncpus'] - hostinfo['mem'] = None if host['maxmem'] == '-' else int(float(host['maxmem'][:-1])*1024) - hostinfo['swap'] = None if host['maxswp'] == '-' else int(float(host['maxswp'][:-1])*1024) + hostinfo['mem'] = None if host['maxmem'] == '-' else transferMemToMB(host['maxmem']) + hostinfo['swap'] = None if host['maxswp'] == '-' else transferMemToMB(host['maxswp']) hostinfo['cpuModel'] = host['model'] hostinfo['cpuBuildType'] = 'x86_64' if host['type'] == 'X86_64' else host['type'] if (hostinfo['state'] == 'CLOSED' and hostinfo['coreFree'] == 0):