def __init__(self): self.nodesMemSample = {} numaTopology = numa.topology() for nodeIndex in numaTopology: nodeMemSample = {} memInfo = numa.memory_by_cell(int(nodeIndex)) nodeMemSample['memFree'] = memInfo['free'] # in case the numa node has zero memory assigned, report the whole # memory as used nodeMemSample['memPercent'] = 100 if int(memInfo['total']) != 0: nodeMemSample['memPercent'] = 100 - \ int(100.0 * int(memInfo['free']) / int(memInfo['total'])) self.nodesMemSample[nodeIndex] = nodeMemSample
def __init__(self): self.nodesMemSample = {} numaTopology = numa.topology() for nodeIndex in numaTopology: nodeMemSample = {} # work around libvirt bug (if not built with numactl) if len(numaTopology) == 1: idx = -1 else: idx = int(nodeIndex) memInfo = numa.memory_by_cell(idx) nodeMemSample['memFree'] = memInfo['free'] # in case the numa node has zero memory assigned, report the whole # memory as used nodeMemSample['memPercent'] = 100 if int(memInfo['total']) != 0: nodeMemSample['memPercent'] = 100 - \ int(100.0 * int(memInfo['free']) // int(memInfo['total'])) self.nodesMemSample[nodeIndex] = nodeMemSample