Always enable CPU and Memory stats polling.

Not sure why I even added this in the first place, we fundamentally can't
avoid polling the requisit info. So rip it out with extreme prejudice.
This commit is contained in:
Cole Robinson
2009-07-26 16:09:46 -04:00
parent 29729db74a
commit e33018602d
7 changed files with 100 additions and 242 deletions

View File

@@ -143,32 +143,6 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/stats/enable-mem-poll</key>
<applyto>/apps/::PACKAGE::/stats/enable-mem-poll</applyto>
<owner>::PACKAGE::</owner>
<type>bool</type>
<default>1</default>
<locale name="C">
<short>Poll memory usage stats</short>
<long>Whether or not the app will poll connection and VM memory usage statistics</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/stats/enable-cpu-poll</key>
<applyto>/apps/::PACKAGE::/stats/enable-cpu-poll</applyto>
<owner>::PACKAGE::</owner>
<type>bool</type>
<default>1</default>
<locale name="C">
<short>Poll cpu stats</short>
<long>Whether or not the app will poll connection and VM cpu usage statistics</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/::PACKAGE::/urls/url-list-length</key>
<applyto>/apps/::PACKAGE::/urls/url-list-length</applyto>

View File

@@ -360,19 +360,11 @@ class vmmConfig:
return self.conf.get_bool(self.conf_dir + "/stats/enable-disk-poll")
def get_stats_enable_net_poll(self):
return self.conf.get_bool(self.conf_dir + "/stats/enable-net-poll")
def get_stats_enable_mem_poll(self):
return self.conf.get_bool(self.conf_dir + "/stats/enable-mem-poll")
def get_stats_enable_cpu_poll(self):
return self.conf.get_bool(self.conf_dir + "/stats/enable-cpu-poll")
def set_stats_enable_disk_poll(self, val):
self.conf.set_bool(self.conf_dir + "/stats/enable-disk-poll", val)
def set_stats_enable_net_poll(self, val):
self.conf.set_bool(self.conf_dir + "/stats/enable-net-poll", val)
def set_stats_enable_mem_poll(self, val):
self.conf.set_bool(self.conf_dir + "/stats/enable-mem-poll", val)
def set_stats_enable_cpu_poll(self, val):
self.conf.set_bool(self.conf_dir + "/stats/enable-cpu-poll", val)
def on_stats_enable_disk_poll_changed(self, cb, userdata=None):
self.conf.notify_add(self.conf_dir + "/stats/enable-disk-poll", cb,
@@ -380,12 +372,6 @@ class vmmConfig:
def on_stats_enable_net_poll_changed(self, cb, userdata=None):
self.conf.notify_add(self.conf_dir + "/stats/enable-net-poll", cb,
userdata)
def on_stats_enable_mem_poll_changed(self, cb, userdata=None):
self.conf.notify_add(self.conf_dir + "/stats/enable-mem-poll", cb,
userdata)
def on_stats_enable_cpu_poll_changed(self, cb, userdata=None):
self.conf.notify_add(self.conf_dir + "/stats/enable-cpu-poll", cb,
userdata)
# VM Console preferences
def on_console_popup_changed(self, callback):

View File

@@ -930,14 +930,13 @@ class vmmDetails(gobject.GObject):
dsk_txt = _("Disabled")
net_txt = _("Disabled")
if self.config.get_stats_enable_cpu_poll():
cpu_txt = "%d %%" % self.vm.cpu_time_percentage()
cpu_txt = "%d %%" % self.vm.cpu_time_percentage()
vm_memory = self.vm.current_memory()
host_memory = self.vm.get_connection().host_memory_size()
mem_txt = "%d MB of %d MB" % (int(round(vm_memory/1024.0)),
int(round(host_memory/1024.0)))
if self.config.get_stats_enable_mem_poll():
vm_memory = self.vm.current_memory()
host_memory = self.vm.get_connection().host_memory_size()
mem_txt = "%d MB of %d MB" % (int(round(vm_memory/1024.0)),
int(round(host_memory/1024.0)))
if self.config.get_stats_enable_disk_poll():
dsk_txt = _rx_tx_text(self.vm.disk_read_rate(),
self.vm.disk_write_rate(), "KB/s")

View File

@@ -66,23 +66,17 @@ class vmmDomain(gobject.GObject):
self._orig_inactive_xml = None
self._valid_xml = False
self._mem_stats = None
self._cpu_stats = None
self._network_traffic = None
self._disk_io = None
self._update_status()
self.config.on_stats_enable_mem_poll_changed(self.toggle_sample_mem_stats)
self.config.on_stats_enable_cpu_poll_changed(self.toggle_sample_cpu_stats)
self.config.on_stats_enable_net_poll_changed(self.toggle_sample_network_traffic)
self.config.on_stats_enable_disk_poll_changed(self.toggle_sample_disk_io)
self._stats_net_supported = True
self._stats_disk_supported = True
self.toggle_sample_mem_stats()
self.toggle_sample_cpu_stats()
self.toggle_sample_network_traffic()
self.toggle_sample_disk_io()
@@ -297,17 +291,11 @@ class vmmDomain(gobject.GObject):
self.config.on_console_scaling_changed, cb)
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
@@ -417,8 +405,8 @@ class vmmDomain(gobject.GObject):
if self.get_id() == 0:
info[1] = self.connection.host_memory_size()
cpuTime, cpuTimeAbs, pcentCpuTime = self._cpu_stats(info, now)
pcentCurrMem, pcentMaxMem = self._mem_stats(info)
cpuTime, cpuTimeAbs, pcentCpuTime = self._sample_cpu_stats(info, now)
pcentCurrMem, pcentMaxMem = self._sample_mem_stats(info)
rdBytes, wrBytes = self._disk_io()
rxBytes, txBytes = self._network_traffic()
@@ -1457,20 +1445,6 @@ class vmmDomain(gobject.GObject):
self.redefine(util.xml_parse_wrapper,
change_label)
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():

View File

@@ -149,10 +149,6 @@ class vmmManager(gobject.GObject):
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)
@@ -329,11 +325,7 @@ class vmmManager(gobject.GObject):
[ (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.config.get_stats_enable_net_poll())]:
self.enable_polling(None, None, init_val, typ)
self.window.get_widget("menu_file_restore_saved").set_sensitive(False)
@@ -1025,11 +1017,7 @@ class vmmManager(gobject.GObject):
col.set_visible(self.config.is_vmlist_cpu_usage_visible())
def enable_polling(self, ignore1, ignore2, conf_entry, userdata):
if userdata == VMLIST_SORT_CPU_USAGE:
widgn = "menu_view_cpu_usage"
elif userdata == VMLIST_SORT_MEMORY_USAGE:
widgn = "menu_view_memory_usage"
elif userdata == VMLIST_SORT_DISK_IO:
if userdata == VMLIST_SORT_DISK_IO:
widgn = "menu_view_disk_io"
elif userdata == VMLIST_SORT_NETWORK_USAGE:
widgn = "menu_view_network_traffic"

View File

@@ -46,8 +46,6 @@ class vmmPreferences(gobject.GObject):
self.config.on_sound_remote_changed(self.refresh_sound_remote)
self.config.on_stats_enable_disk_poll_changed(self.refresh_disk_poll)
self.config.on_stats_enable_net_poll_changed(self.refresh_net_poll)
self.config.on_stats_enable_mem_poll_changed(self.refresh_mem_poll)
self.config.on_stats_enable_cpu_poll_changed(self.refresh_cpu_poll)
self.refresh_update_interval()
self.refresh_history_length()
@@ -58,8 +56,6 @@ class vmmPreferences(gobject.GObject):
self.refresh_sound_remote()
self.refresh_disk_poll()
self.refresh_net_poll()
self.refresh_mem_poll()
self.refresh_cpu_poll()
self.window.signal_autoconnect({
"on_prefs_stats_update_interval_changed": self.change_update_interval,
@@ -74,8 +70,6 @@ class vmmPreferences(gobject.GObject):
"on_prefs_sound_remote_toggled": self.change_remote_sound,
"on_prefs_stats_enable_disk_toggled": self.change_disk_poll,
"on_prefs_stats_enable_net_toggled": self.change_net_poll,
"on_prefs_stats_enable_mem_toggled": self.change_mem_poll,
"on_prefs_stats_enable_cpu_toggled": self.change_cpu_poll,
})
def close(self, ignore1=None, ignore2=None):
@@ -121,12 +115,6 @@ class vmmPreferences(gobject.GObject):
def refresh_net_poll(self, ignore1=None, ignore2=None, ignore3=None,
ignore4=None):
self.window.get_widget("prefs-stats-enable-net").set_active(self.config.get_stats_enable_net_poll())
def refresh_mem_poll(self, ignore1=None, ignore2=None, ignore3=None,
ignore4=None):
self.window.get_widget("prefs-stats-enable-mem").set_active(self.config.get_stats_enable_mem_poll())
def refresh_cpu_poll(self, ignore1=None, ignore2=None, ignore3=None,
ignore4=None):
self.window.get_widget("prefs-stats-enable-cpu").set_active(self.config.get_stats_enable_cpu_poll())
def change_update_interval(self, src):
self.config.set_stats_update_interval(src.get_value_as_int())
@@ -149,10 +137,6 @@ class vmmPreferences(gobject.GObject):
self.config.set_stats_enable_disk_poll(src.get_active())
def change_net_poll(self, src):
self.config.set_stats_enable_net_poll(src.get_active())
def change_mem_poll(self, src):
self.config.set_stats_enable_mem_poll(src.get_active())
def change_cpu_poll(self, src):
self.config.set_stats_enable_cpu_poll(src.get_active())
def show_help(self, src):
# From the Preferences window, show the help document from

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Thu Feb 12 14:51:35 2009 -->
<!--Generated with glade3 3.4.5 on Wed Jul 22 23:26:58 2009 -->
<glade-interface>
<widget class="GtkWindow" id="vmm-preferences">
<property name="title" translatable="yes">Preferences</property>
@@ -38,27 +38,34 @@
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label9">
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">samples</property>
<property name="label" translatable="yes">Update status every</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maintain history of</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkSpinButton" id="prefs-stats-update-interval">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 60 1 5 0</property>
<signal name="value_changed" handler="on_prefs_stats_update_interval_changed"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -78,36 +85,29 @@
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="prefs-stats-update-interval">
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 60 1 5 0</property>
<signal name="value_changed" handler="on_prefs_stats_update_interval_changed"/>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label7">
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maintain history of</property>
<property name="label" translatable="yes">samples</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Update status every</property>
</widget>
</child>
</widget>
</child>
</widget>
@@ -144,19 +144,37 @@
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-net">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_net_toggled"/>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disk I/O</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_EXPAND</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Network I/O</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -170,18 +188,16 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-mem">
<widget class="GtkCheckButton" id="prefs-stats-enable-net">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_mem_toggled"/>
<signal name="toggled" handler="on_prefs_stats_enable_net_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -191,67 +207,6 @@
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="prefs-stats-enable-cpu">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_prefs_stats_enable_cpu_toggled"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Network I/O</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Disk I/O</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Memory Usage</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">CPU Usage</property>
<property name="ellipsize">PANGO_ELLIPSIZE_END</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
@@ -302,31 +257,37 @@
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="n_rows">6</property>
<property name="n_columns">1</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkComboBox" id="prefs-console-scaling">
<widget class="GtkComboBox" id="prefs-console-popup">
<property name="visible">True</property>
<property name="items" translatable="yes">Never
Fullscreen only
Always</property>
<signal name="changed" handler="on_prefs_console_scaling_changed"/>
For all new domains
For all domains</property>
<signal name="changed" handler="on_prefs_console_popup_changed"/>
</widget>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_padding">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Graphical Console Scaling:</property>
<property name="label" translatable="yes">Automatically open consoles:</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grab keyboard input:</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
@@ -344,34 +305,27 @@ On mouse over</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grab keyboard input:</property>
<property name="label" translatable="yes">Graphical Console Scaling:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Automatically open consoles:</property>
</widget>
</child>
<child>
<widget class="GtkComboBox" id="prefs-console-popup">
<widget class="GtkComboBox" id="prefs-console-scaling">
<property name="visible">True</property>
<property name="items" translatable="yes">Never
For all new domains
For all domains</property>
<signal name="changed" handler="on_prefs_console_popup_changed"/>
Fullscreen only
Always</property>
<signal name="changed" handler="on_prefs_console_scaling_changed"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">5</property>
</packing>
</child>
@@ -407,8 +361,14 @@ For all domains</property>
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<property name="column_spacing">8</property>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install Audio Device:</property>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
@@ -447,13 +407,6 @@ For all domains</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install Audio Device:</property>
</widget>
</child>
</widget>
</child>
</widget>