The attached patch hooks up the new preferences options to
enable/disable stats polling.
When polling is disabled, performance graphs in the VM Details->Overview
tab are labeled as 'Disabled'. The graphs continue to update, but all
the data passed to it is 0:
Also, if the associated stats column is visible in the manager window
when the user disables polling, the manager column disappears. The
View-> entry for that stats type is also disabled, with a tooltip
informing the user that polling is disabled in the preferences dialog.
Thanks,
Cole
# HG changeset patch
# User "Cole Robinson <crobinso@redhat.com>"
# Date 1228749285 18000
# Node ID 31d00d8e89d2f073c727d4952b04650eb7c54d0c
# Parent c7cd0d65d7a67da18e6b7b44e5bbee98710569ce
Hook up new global stats enable/disable work.
def get_xml(self):
if self.xml is None:
@@ -161,6 +169,47 @@
self.lastStatus = status
self.emit("status-changed", status)
+ def _sample_mem_stats_dummy(self, ignore):
+ return 0, 0
+
+ def _sample_mem_stats(self, info):
+ pcentCurrMem = info[2] * 100.0 / self.connection.host_memory_size()
+ pcentMaxMem = info[1] * 100.0 / self.connection.host_memory_size()
+ return pcentCurrMem, pcentMaxMem
+
+ def _sample_cpu_stats_dummy(self, ignore, ignore1):
+ return 0, 0, 0
+
+ def _sample_cpu_stats(self, info, now):
+ prevCpuTime = 0
+ prevTimestamp = 0
+ if len(self.record) > 0:
+ prevTimestamp = self.record[0]["timestamp"]
+ prevCpuTime = self.record[0]["cpuTimeAbs"]
+
+ cpuTime = 0
+ cpuTimeAbs = 0
+ pcentCpuTime = 0
+ if not (info[0] in [libvirt.VIR_DOMAIN_SHUTOFF,
+ libvirt.VIR_DOMAIN_CRASHED]):
+ cpuTime = info[4] - prevCpuTime
+ cpuTimeAbs = info[4]
+
+ pcentCpuTime = ((cpuTime) * 100.0 /
+ (((now - prevTimestamp)*1000.0*1000.0*1000.0) *
+ self.connection.host_active_processor_count()))
+ # Due to timing diffs between getting wall time & getting
+ # the domain's time, its possible to go a tiny bit over
+ # 100% utilization. This freaks out users of the data, so
+ # we hard limit it.
+ if pcentCpuTime > 100.0:
+ pcentCpuTime = 100.0
+ # Enforce >= 0 just in case
+ if pcentCpuTime < 0.0:
+ pcentCpuTime = 0.0
+
+ return cpuTime, cpuTimeAbs, pcentCpuTime
+
def _sample_network_traffic_dummy(self):
return 0, 0
@@ -208,6 +257,7 @@
def tick(self, now):
if self.connection.get_state() != self.connection.STATE_ACTIVE:
return
+
# Clear cached XML
self.xml = None
info = self.vm.info()
@@ -215,30 +265,6 @@
current = len(self.record)
if current > expected:
del self.record[expected:current]
-
- prevCpuTime = 0
- prevTimestamp = 0
- if len(self.record) > 0:
- prevTimestamp = self.record[0]["timestamp"]
- prevCpuTime = self.record[0]["cpuTimeAbs"]
-
- cpuTime = 0
- cpuTimeAbs = 0
- pcentCpuTime = 0
- if not(info[0] in [libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED]):
- cpuTime = info[4] - prevCpuTime
- cpuTimeAbs = info[4]
-
- pcentCpuTime = (cpuTime) * 100.0 / ((now - prevTimestamp)*1000.0*1000.0*1000.0*self.connectio n.host_active_processor_count())
- # Due to timing diffs between getting wall time & getting
- # the domain's time, its possible to go a tiny bit over
- # 100% utilization. This freaks out users of the data, so
- # we hard limit it.
- if pcentCpuTime > 100.0:
- pcentCpuTime = 100.0
- # Enforce >= 0 just in case
- if pcentCpuTime < 0.0:
- pcentCpuTime = 0.0
# Xen reports complete crap for Dom0 max memory
# (ie MAX_LONG) so lets clamp it to the actual
@@ -248,9 +274,8 @@
if self.get_id() == 0:
info[1] = self.connection.host_memory_size()
- def toggle_sample_network_traffic(self, ignore1=None, ignore2=None, ignore3=None, ignore4=None):
- if self.config.is_vmlist_network_traffic_visible():
+ def toggle_sample_cpu_stats(self, ignore1=None, ignore2=None,
+ ignore3=None, ignore4=None):
+ if self.config.get_stats_enable_cpu_poll():
+ self._cpu_stats = self._sample_cpu_stats
+ else:
+ self._cpu_stats = self._sample_cpu_stats_dummy
+
+ def toggle_sample_mem_stats(self, ignore1=None, ignore2=None,
+ ignore3=None, ignore4=None):
+ if self.config.get_stats_enable_mem_poll():
+ self._mem_stats = self._sample_mem_stats
+ else:
+ self._mem_stats = self._sample_mem_stats_dummy
+
+ def toggle_sample_network_traffic(self, ignore1=None, ignore2=None,
+ ignore3=None, ignore4=None):
+ if self.config.get_stats_enable_net_poll():
if len(self.record) > 1:
# resample the current value before calculating the rate in
# self.tick() otherwise we'd get a huge spike when switching
@@ -1086,8 +1125,9 @@
else:
self._network_traffic = self._sample_network_traffic_dummy
- def toggle_sample_disk_io(self, ignore1=None, ignore2=None, ignore3=None, ignore4=None):
- if self.config.is_vmlist_disk_io_visible():
+ def toggle_sample_disk_io(self, ignore1=None, ignore2=None,
+ ignore3=None, ignore4=None):
+ if self.config.get_stats_enable_disk_poll():
if len(self.record) > 1:
# resample the current value before calculating the rate in
# self.tick() otherwise we'd get a huge spike when switching
diff -r c7cd0d65d7a6 -r 31d00d8e89d2 src/virtManager/manager.py
--- a/src/virtManager/manager.py Mon Dec 08 10:11:25 2008 -0500
+++ b/src/virtManager/manager.py Mon Dec 08 10:14:45 2008 -0500
@@ -136,6 +136,17 @@
self.window.get_widget("menu_view_disk_io").set_ac tive(self.config.is_vmlist_disk_io_visible())
self.window.get_widget("menu_view_network_traffic" ).set_active(self.config.is_vmlist_network_traffic _visible())
+ # Register callbacks with the global stats enable/disable values
+ # that disable the associated vmlist widgets if reporting is disabled
+ self.config.on_stats_enable_disk_poll_changed(self .enable_polling,
+ VMLIST_SORT_DISK_IO)
+ self.config.on_stats_enable_net_poll_changed(self. enable_polling,
+ VMLIST_SORT_NETWORK_USAGE)
+ self.config.on_stats_enable_cpu_poll_changed(self. enable_polling,
+ VMLIST_SORT_CPU_USAGE)
+ self.config.on_stats_enable_mem_poll_changed(self. enable_polling,
+ VMLIST_SORT_MEMORY_USAGE)
+
self.window.get_widget("vm-view").set_active(0)
self.vmmenu_icons = {}
@@ -291,6 +302,19 @@
self.vm_selected(None)
self.window.get_widget("vm-list").get_selection().connect("changed", self.vm_selected)
+
+ # Initialize stat polling columns based on global polling
+ # preferences (we want signal handlers for this)
+ for typ, init_val in
+ [ (VMLIST_SORT_DISK_IO,
+ self.config.get_stats_enable_disk_poll()),
+ (VMLIST_SORT_NETWORK_USAGE,
+ self.config.get_stats_enable_net_poll()),
+ (VMLIST_SORT_CPU_USAGE,
+ self.config.get_stats_enable_cpu_poll()),
+ (VMLIST_SORT_MEMORY_USAGE,
+ self.config.get_stats_enable_mem_poll())]:
+ self.enable_polling(None, None, init_val, typ)
# store any error message from the restore-domain callback
self.domain_restore_error = ""
@@ -981,6 +1005,27 @@
col = vmlist.get_column(COL_CPU)
col.set_visible(self.config.is_vmlist_cpu_usage_vi sible())