mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-27 14:03:57 +03:00
Base mem statistics on virDomainMemoryStats if available.
Attempt to query domain memory stats via virDomainMemoryStats. (crobinso: remove the broken fallback, since it's confusing)
This commit is contained in:
parent
77b1143965
commit
b5da599aef
@ -245,6 +245,8 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
self.remote_console_supported = False
|
self.remote_console_supported = False
|
||||||
self.title_supported = False
|
self.title_supported = False
|
||||||
|
|
||||||
|
self._mem_stats_supported = True
|
||||||
|
|
||||||
self._enable_net_poll = False
|
self._enable_net_poll = False
|
||||||
self._stats_net_supported = True
|
self._stats_net_supported = True
|
||||||
self._stats_net_skip = []
|
self._stats_net_skip = []
|
||||||
@ -1359,12 +1361,26 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
# Stats helpers ###
|
# Stats helpers ###
|
||||||
###################
|
###################
|
||||||
|
|
||||||
def _sample_mem_stats(self, info):
|
def _sample_mem_stats(self):
|
||||||
curmem = info[2]
|
curmem = 0
|
||||||
if not self.is_active():
|
totalmem = 1
|
||||||
curmem = 0
|
|
||||||
|
|
||||||
pcentCurrMem = curmem * 100.0 / self.maximum_memory()
|
if self._mem_stats_supported and self.is_active():
|
||||||
|
try:
|
||||||
|
stats = self._backend.memoryStats()
|
||||||
|
# did we get both required stat items back?
|
||||||
|
if set(['actual', 'rss']).issubset(
|
||||||
|
set(stats.keys())):
|
||||||
|
curmem = stats['rss']
|
||||||
|
totalmem = stats['actual']
|
||||||
|
except libvirt.libvirtError, err:
|
||||||
|
if util.is_error_nosupport(err):
|
||||||
|
logging.debug("Mem stats not supported: %s", err)
|
||||||
|
self._mem_stats_supported = False
|
||||||
|
else:
|
||||||
|
logging.error("Error reading mem stats: %s", err)
|
||||||
|
|
||||||
|
pcentCurrMem = curmem * 100.0 / totalmem
|
||||||
pcentCurrMem = max(0.0, min(pcentCurrMem, 100.0))
|
pcentCurrMem = max(0.0, min(pcentCurrMem, 100.0))
|
||||||
|
|
||||||
return pcentCurrMem, curmem
|
return pcentCurrMem, curmem
|
||||||
@ -1767,7 +1783,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
now = time.time()
|
now = time.time()
|
||||||
(cpuTime, cpuTimeAbs,
|
(cpuTime, cpuTimeAbs,
|
||||||
pcentHostCpu, pcentGuestCpu) = self._sample_cpu_stats(info, now)
|
pcentHostCpu, pcentGuestCpu) = self._sample_cpu_stats(info, now)
|
||||||
pcentCurrMem, curmem = self._sample_mem_stats(info)
|
pcentCurrMem, curmem = self._sample_mem_stats()
|
||||||
rdBytes, wrBytes = self._sample_disk_io()
|
rdBytes, wrBytes = self._sample_disk_io()
|
||||||
rxBytes, txBytes = self._sample_network_traffic()
|
rxBytes, txBytes = self._sample_network_traffic()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user