Hi, this patch allows to disale the sampling of net/block stats - triggered via the vmlist-fields/{network_traffic,disk_io} gconf keys. We do this by replacing the sampling routines with noops. Also adjust the label in the vm details to say "sampling disabled". -- Guido
# HG changeset patch # User "Guido Günther <agx@xxxxxxxxxxx>" # Date 1224358185 -7200 # Node ID 4dbdefea266a50d064e358d4376d7489f99190f8 # Parent 2728eac561fb8f07f7499f95766b22ee016ba7e2 allow to disable sampling triggered via the vmlist-fields/{network_traffic,disk_io} gconf keys. We do this by replacing the sampling routines with noops. Also adjust the label in the vm details to say "sampling disabled". diff -r 2728eac561fb -r 4dbdefea266a src/virtManager/details.py --- a/src/virtManager/details.py Sat Oct 18 21:28:57 2008 +0200 +++ b/src/virtManager/details.py Sat Oct 18 21:29:45 2008 +0200 @@ -814,20 +814,24 @@ self.window.get_widget("overview-memory-usage-text").set_text("%d MB of %d MB" % \ (int(round(vm_memory/1024.0)), \ int(round(host_memory/1024.0)))) - self.window.get_widget("overview-network-traffic-text").set_markup(_rx_tx_text( - self.vm.network_rx_rate(), - self.vm.network_tx_rate(), - "KBytes/s")) - self.window.get_widget("overview-disk-usage-text").set_markup(_rx_tx_text( - self.vm.disk_read_rate(), - self.vm.disk_write_rate(), - "KBytes/s")) history_len = self.config.get_stats_history_length() self.cpu_usage_graph.set_property("data_array", self.vm.cpu_time_vector()) self.memory_usage_graph.set_property("data_array", self.vm.current_memory_vector()) - self.network_traffic_graph.set_property("data_array", self.vm.network_traffic_vector()) - self.disk_io_graph.set_property("data_array", self.vm.disk_io_vector()) + + if self.config.is_vmlist_network_traffic_visible(): + text = _rx_tx_text(self.vm.network_rx_rate(), self.vm.network_tx_rate(), "KBytes/s") + self.network_traffic_graph.set_property("data_array", self.vm.network_traffic_vector()) + else: + text = "sampling\ndisabled" + self.window.get_widget("overview-network-traffic-text").set_markup(text) + + if self.config.is_vmlist_disk_io_visible(): + text = _rx_tx_text(self.vm.disk_read_rate(), self.vm.disk_write_rate(), "KBytes/s") + self.disk_io_graph.set_property("data_array", self.vm.disk_io_vector()) + else: + text = "sampling\ndisabled" + self.window.get_widget("overview-disk-usage-text").set_markup(text) def refresh_config_cpu(self): self.window.get_widget("state-host-cpus").set_text("%d" % self.vm.get_connection().host_active_processor_count()) diff -r 2728eac561fb -r 4dbdefea266a src/virtManager/domain.py --- a/src/virtManager/domain.py Sat Oct 18 21:28:57 2008 +0200 +++ b/src/virtManager/domain.py Sat Oct 18 21:29:45 2008 +0200 @@ -53,6 +53,11 @@ self._update_status() self.xml = None + + self.config.on_vmlist_network_traffic_visible_changed(self.toggle_sample_network_traffic) + self.toggle_sample_network_traffic() + self.config.on_vmlist_disk_io_visible_changed(self.toggle_sample_disk_io) + self.toggle_sample_disk_io() def get_xml(self): if self.xml is None: @@ -155,7 +160,10 @@ self.lastStatus = status self.emit("status-changed", status) - def _network_traffic(self): + def _sample_network_traffic_dummy(self): + return 0, 0 + + def _sample_network_traffic(self): rx = 0 tx = 0 for netdev in self.get_network_devices(): @@ -168,7 +176,10 @@ logging.error("Error reading interface stats %s" % err) return rx, tx - def _disk_io(self): + def _sample_disk_io_dummy(self): + return 0, 0 + + def _sample_disk_io(self): rd = 0 wr = 0 for disk in self.get_disk_devices(): @@ -1065,4 +1076,31 @@ # Invalidate cached xml self.xml = None + def toggle_sample_network_traffic(self, ignore1=None, ignore2=None, ignore3=None, ignore4=None): + if self.config.is_vmlist_network_traffic_visible(): + 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 + # from 0 to bytes_transfered_so_far + rxBytes, txBytes = self._sample_network_traffic() + self.record[0]["netRxKB"] = rxBytes / 1024 + self.record[0]["netTxKB"] = txBytes / 1024 + self._network_traffic = self._sample_network_traffic + 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(): + 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 + # from 0 to bytes_transfered_so_far + rdBytes, wrBytes = self._sample_disk_io() + self.record[0]["diskRdKB"] = rdBytes / 1024 + self.record[0]["diskWrKB"] = wrBytes / 1024 + self._disk_io = self._sample_disk_io + else: + self._disk_io = self._sample_disk_io_dummy + + gobject.type_register(vmmDomain)
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools