mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +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.
|
||||
"""
|
||||
get_all_mem = self.wvm.getInfo()[1] * 1048576
|
||||
get_freemem = self.wvm.getMemoryStats(-1, 0)
|
||||
if type(get_freemem) == dict:
|
||||
free = (get_freemem.values()[0] +
|
||||
get_freemem.values()[2] +
|
||||
get_freemem.values()[3]) * 1024
|
||||
percent = (100 - ((free * 100) / get_all_mem))
|
||||
usage = (get_all_mem - free)
|
||||
mem_usage = {'usage': usage, 'percent': percent}
|
||||
all_mem = self.wvm.getInfo()[1] * 1048576
|
||||
freemem = self.wvm.getMemoryStats(-1, 0)
|
||||
if type(freemem) == dict:
|
||||
free = (freemem.values()[0] +
|
||||
freemem.values()[2] +
|
||||
freemem.values()[3]) * 1024
|
||||
percent = (100 - ((free * 100) / all_mem))
|
||||
usage = (all_mem - free)
|
||||
mem_usage = {'total': all_mem, 'usage': usage, 'percent': percent}
|
||||
else:
|
||||
mem_usage = {'usage': None, 'percent': None}
|
||||
mem_usage = {'total': None, 'usage': None, 'percent': None}
|
||||
return mem_usage
|
||||
|
||||
def get_cpu_usage(self):
|
||||
|
|
Loading…
Reference in a new issue