mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Add total memory info for memory usage and change var names
This commit is contained in:
parent
a0147818b9
commit
455f239093
1 changed files with 10 additions and 10 deletions
|
@ -16,17 +16,17 @@ class wvmHostDetails(wvmConnect):
|
||||||
"""
|
"""
|
||||||
Function return memory usage on node.
|
Function return memory usage on node.
|
||||||
"""
|
"""
|
||||||
get_all_mem = self.wvm.getInfo()[1] * 1048576
|
all_mem = self.wvm.getInfo()[1] * 1048576
|
||||||
get_freemem = self.wvm.getMemoryStats(-1, 0)
|
freemem = self.wvm.getMemoryStats(-1, 0)
|
||||||
if type(get_freemem) == dict:
|
if type(freemem) == dict:
|
||||||
free = (get_freemem.values()[0] +
|
free = (freemem.values()[0] +
|
||||||
get_freemem.values()[2] +
|
freemem.values()[2] +
|
||||||
get_freemem.values()[3]) * 1024
|
freemem.values()[3]) * 1024
|
||||||
percent = (100 - ((free * 100) / get_all_mem))
|
percent = (100 - ((free * 100) / all_mem))
|
||||||
usage = (get_all_mem - free)
|
usage = (all_mem - free)
|
||||||
mem_usage = {'usage': usage, 'percent': percent}
|
mem_usage = {'total': all_mem, 'usage': usage, 'percent': percent}
|
||||||
else:
|
else:
|
||||||
mem_usage = {'usage': None, 'percent': None}
|
mem_usage = {'total': None, 'usage': None, 'percent': None}
|
||||||
return mem_usage
|
return mem_usage
|
||||||
|
|
||||||
def get_cpu_usage(self):
|
def get_cpu_usage(self):
|
||||||
|
|
Loading…
Reference in a new issue