[PATCH 9/9]: virt-manager: add sparcline to vm/connection overview

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Finally display a combined sparcline for rx & tx (network) and input &
output (disk) in the Network I/O and Disk I/O columns in the vm machine
overview.
 -- Guido

diff -r 134368ad3def src/virtManager/connection.py
--- a/src/virtManager/connection.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/connection.py	Sat Oct 04 17:27:01 2008 +0200
@@ -1056,6 +1056,14 @@
 
     def disk_io_rate(self):
         return self.disk_read_rate() + self.disk_write_rate()
+       
+    def disk_io_vector_limit(self, dummy):
+        """No point to accumulate unnormalized I/O for a conenction"""
+        return [ 0.0 ]
+
+    def network_traffic_vector_limit(self, dummy):
+        """No point to accumulate unnormalized Rx/Tx for a conenction"""
+        return [ 0.0 ]
 
     def uuidstr(self, rawuuid):
         hex = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
diff -r 134368ad3def src/virtManager/domain.py
--- a/src/virtManager/domain.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/domain.py	Sat Oct 04 17:27:01 2008 +0200
@@ -422,6 +422,14 @@
                 vector.append(0)
         return vector
 
+    def in_out_vector_limit(self, data, limit):
+        l = len(data)/2
+        end = [l, limit][l > limit]
+        if l > limit:
+            data = data[0:end] + data[l:l+end]
+        d = map(lambda x,y: (x + y)/2, data[0:end], data[l:l+end]) 
+        return d
+
     def network_traffic_vector(self):
         vector = []
         stats = self.record
@@ -434,6 +442,9 @@
                     vector.append(0.0)
         return vector
 
+    def network_traffic_vector_limit(self, limit):
+        return self.in_out_vector_limit(self.network_traffic_vector(), limit)
+
     def disk_io_vector(self):
         vector = []
         stats = self.record
@@ -445,6 +456,9 @@
                 else:
                     vector.append(0.0)
         return vector
+
+    def disk_io_vector_limit(self, limit):
+        return self.in_out_vector_limit(self.disk_io_vector(), limit)
 
     def shutdown(self):
         self.vm.shutdown()
diff -r 134368ad3def src/virtManager/manager.py
--- a/src/virtManager/manager.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/manager.py	Sat Oct 04 17:27:01 2008 +0200
@@ -863,6 +863,7 @@
 
         cpuUsage_txt = gtk.CellRendererText()
         cpuUsage_img = sparkline.CellRendererSparkline()
+        cpuUsage_img.set_property("reversed", True)
         cpuUsageCol.pack_start(cpuUsage_txt, False)
         cpuUsageCol.pack_start(cpuUsage_img, False)
         cpuUsageCol.add_attribute(cpuUsage_txt, 'text', ROW_CPU)
@@ -886,19 +887,27 @@
 
         diskIOIn_txt = gtk.CellRendererText()
         diskIOOut_txt = gtk.CellRendererText()
+        diskIO_img = sparkline.CellRendererSparkline()
+        diskIO_img.set_property("reversed", True)
         diskIOCol.pack_start(diskIOIn_txt, False)
         diskIOCol.pack_start(diskIOOut_txt, False)
+        diskIOCol.pack_start(diskIO_img, False)
         diskIOCol.add_attribute(diskIOIn_txt, 'text', ROW_DISK_RD)
         diskIOCol.add_attribute(diskIOOut_txt, 'text', ROW_DISK_WR)
+        diskIOCol.set_cell_data_func(diskIO_img, self.disk_io_img, None)
         diskIOCol.set_visible(self.config.is_vmlist_disk_io_visible())
         diskIOCol.set_sort_column_id(VMLIST_SORT_DISK_IO)
 
         networkTrafficIn_txt = gtk.CellRendererText()
         networkTrafficOut_txt = gtk.CellRendererText()
+        networkTraffic_img = sparkline.CellRendererSparkline()
+        networkTraffic_img.set_property("reversed", True)
         networkTrafficCol.pack_start(networkTrafficIn_txt, False)
         networkTrafficCol.pack_start(networkTrafficOut_txt, False)
+        networkTrafficCol.pack_start(networkTraffic_img, False)
         networkTrafficCol.add_attribute(networkTrafficIn_txt, 'text', ROW_NET_RX)
         networkTrafficCol.add_attribute(networkTrafficOut_txt, 'text', ROW_NET_TX)
+        networkTrafficCol.set_cell_data_func(networkTraffic_img, self.network_traffic_img, None)
         networkTrafficCol.set_visible(self.config.is_vmlist_network_traffic_visible())
         networkTrafficCol.set_sort_column_id(VMLIST_SORT_NETWORK_USAGE)
 
@@ -997,7 +1006,18 @@
         if model.get_value(iter, ROW_HANDLE) is None:
             return
         data = model.get_value(iter, ROW_HANDLE).cpu_time_vector_limit(40)
-        data.reverse()
+        cell.set_property('data_array', data)
+
+    def disk_io_img(self,  column, cell, model, iter, data):
+        if model.get_value(iter, ROW_HANDLE) is None:
+            return
+        data = model.get_value(iter, ROW_HANDLE).disk_io_vector_limit(40)
+        cell.set_property('data_array', data)
+
+    def network_traffic_img(self,  column, cell, model, iter, data):
+        if model.get_value(iter, ROW_HANDLE) is None:
+            return
+        data = model.get_value(iter, ROW_HANDLE).network_traffic_vector_limit(40)
         cell.set_property('data_array', data)
 
     def start_vm(self, ignore):
Display a combined sparcline for rx & tx (network) and input & output (disk) in
the Network I/O and Disk I/O columns in the vm machine overview.

diff -r 134368ad3def src/virtManager/connection.py
--- a/src/virtManager/connection.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/connection.py	Sat Oct 04 17:27:01 2008 +0200
@@ -1056,6 +1056,14 @@
 
     def disk_io_rate(self):
         return self.disk_read_rate() + self.disk_write_rate()
+       
+    def disk_io_vector_limit(self, dummy):
+        """No point to accumulate unnormalized I/O for a conenction"""
+        return [ 0.0 ]
+
+    def network_traffic_vector_limit(self, dummy):
+        """No point to accumulate unnormalized Rx/Tx for a conenction"""
+        return [ 0.0 ]
 
     def uuidstr(self, rawuuid):
         hex = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
diff -r 134368ad3def src/virtManager/domain.py
--- a/src/virtManager/domain.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/domain.py	Sat Oct 04 17:27:01 2008 +0200
@@ -422,6 +422,14 @@
                 vector.append(0)
         return vector
 
+    def in_out_vector_limit(self, data, limit):
+        l = len(data)/2
+        end = [l, limit][l > limit]
+        if l > limit:
+            data = data[0:end] + data[l:l+end]
+        d = map(lambda x,y: (x + y)/2, data[0:end], data[l:l+end]) 
+        return d
+
     def network_traffic_vector(self):
         vector = []
         stats = self.record
@@ -434,6 +442,9 @@
                     vector.append(0.0)
         return vector
 
+    def network_traffic_vector_limit(self, limit):
+        return self.in_out_vector_limit(self.network_traffic_vector(), limit)
+
     def disk_io_vector(self):
         vector = []
         stats = self.record
@@ -445,6 +456,9 @@
                 else:
                     vector.append(0.0)
         return vector
+
+    def disk_io_vector_limit(self, limit):
+        return self.in_out_vector_limit(self.disk_io_vector(), limit)
 
     def shutdown(self):
         self.vm.shutdown()
diff -r 134368ad3def src/virtManager/manager.py
--- a/src/virtManager/manager.py	Sat Oct 04 17:04:56 2008 +0200
+++ b/src/virtManager/manager.py	Sat Oct 04 17:27:01 2008 +0200
@@ -863,6 +863,7 @@
 
         cpuUsage_txt = gtk.CellRendererText()
         cpuUsage_img = sparkline.CellRendererSparkline()
+        cpuUsage_img.set_property("reversed", True)
         cpuUsageCol.pack_start(cpuUsage_txt, False)
         cpuUsageCol.pack_start(cpuUsage_img, False)
         cpuUsageCol.add_attribute(cpuUsage_txt, 'text', ROW_CPU)
@@ -886,19 +887,27 @@
 
         diskIOIn_txt = gtk.CellRendererText()
         diskIOOut_txt = gtk.CellRendererText()
+        diskIO_img = sparkline.CellRendererSparkline()
+        diskIO_img.set_property("reversed", True)
         diskIOCol.pack_start(diskIOIn_txt, False)
         diskIOCol.pack_start(diskIOOut_txt, False)
+        diskIOCol.pack_start(diskIO_img, False)
         diskIOCol.add_attribute(diskIOIn_txt, 'text', ROW_DISK_RD)
         diskIOCol.add_attribute(diskIOOut_txt, 'text', ROW_DISK_WR)
+        diskIOCol.set_cell_data_func(diskIO_img, self.disk_io_img, None)
         diskIOCol.set_visible(self.config.is_vmlist_disk_io_visible())
         diskIOCol.set_sort_column_id(VMLIST_SORT_DISK_IO)
 
         networkTrafficIn_txt = gtk.CellRendererText()
         networkTrafficOut_txt = gtk.CellRendererText()
+        networkTraffic_img = sparkline.CellRendererSparkline()
+        networkTraffic_img.set_property("reversed", True)
         networkTrafficCol.pack_start(networkTrafficIn_txt, False)
         networkTrafficCol.pack_start(networkTrafficOut_txt, False)
+        networkTrafficCol.pack_start(networkTraffic_img, False)
         networkTrafficCol.add_attribute(networkTrafficIn_txt, 'text', ROW_NET_RX)
         networkTrafficCol.add_attribute(networkTrafficOut_txt, 'text', ROW_NET_TX)
+        networkTrafficCol.set_cell_data_func(networkTraffic_img, self.network_traffic_img, None)
         networkTrafficCol.set_visible(self.config.is_vmlist_network_traffic_visible())
         networkTrafficCol.set_sort_column_id(VMLIST_SORT_NETWORK_USAGE)
 
@@ -997,7 +1006,18 @@
         if model.get_value(iter, ROW_HANDLE) is None:
             return
         data = model.get_value(iter, ROW_HANDLE).cpu_time_vector_limit(40)
-        data.reverse()
+        cell.set_property('data_array', data)
+
+    def disk_io_img(self,  column, cell, model, iter, data):
+        if model.get_value(iter, ROW_HANDLE) is None:
+            return
+        data = model.get_value(iter, ROW_HANDLE).disk_io_vector_limit(40)
+        cell.set_property('data_array', data)
+
+    def network_traffic_img(self,  column, cell, model, iter, data):
+        if model.get_value(iter, ROW_HANDLE) is None:
+            return
+        data = model.get_value(iter, ROW_HANDLE).network_traffic_vector_limit(40)
         cell.set_property('data_array', data)
 
     def start_vm(self, ignore):
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux