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

[Xen-changelog] [xen-unstable] xenapi: Extension to get vif total i/o stats.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1195571889 0
# Node ID 94b3979606cd9c4e9202bc59209b9d0c897f7689
# Parent  2022cbc842af902007b5379acac2ea9fc83aa061
xenapi: Extension to get vif total i/o stats.
From: Stefan de Konink <skinkie@xxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py        |   10 ++++++++++
 tools/python/xen/xend/XendDomainInfo.py |    7 ++++++-
 tools/python/xen/xend/XendMonitor.py    |   14 ++++++++++++++
 tools/python/xen/xend/XendNode.py       |    6 ++++++
 4 files changed, 36 insertions(+), 1 deletion(-)

diff -r 2022cbc842af -r 94b3979606cd tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Nov 20 15:13:29 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Tue Nov 20 15:18:09 2007 +0000
@@ -2111,6 +2111,8 @@ class XendAPI(object):
 
     VIF_metrics_attr_ro = ['io_read_kbs',
                            'io_write_kbs',
+                           'io_total_read_kbs',
+                           'io_total_write_kbs',
                            'last_updated']
     VIF_metrics_attr_rw = []
     VIF_metrics_methods = []
@@ -2125,6 +2127,8 @@ class XendAPI(object):
         return xen_api_success(
             { 'io_read_kbs'  : vm.get_dev_property('vif', ref, 'io_read_kbs'),
               'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs'),
+              'io_total_read_kbs'  : vm.get_dev_property('vif', ref, 
'io_total_read_kbs'),
+              'io_total_write_kbs' : vm.get_dev_property('vif', ref, 
'io_total_write_kbs'),
               'last_updated' : now()
             })
 
@@ -2133,6 +2137,12 @@ class XendAPI(object):
     
     def VIF_metrics_get_io_write_kbs(self, session, ref):
         return self._VIF_get(ref, 'io_write_kbs')
+
+    def VIF_metrics_get_io_total_read_kbs(self, _, ref):
+        return self._VIF_get(ref, 'io_total_read_kbs')
+
+    def VIF_metrics_get_io_total_write_kbs(self, session, ref):
+        return self._VIF_get(ref, 'io_total_write_kbs')
 
     def VIF_metrics_get_last_updated(self, _1, _2):
         return xen_api_success(now())
diff -r 2022cbc842af -r 94b3979606cd tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 20 15:13:29 2007 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 20 15:18:09 2007 +0000
@@ -2606,9 +2606,14 @@ class XendDomainInfo:
                 rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid)
                 config['io_read_kbs'] = rx_bps/1024
                 config['io_write_kbs'] = tx_bps/1024
+                rx, tx = xennode.get_vif_stat(self.domid, devid)
+                config['io_total_read_kbs'] = rx/1024
+                config['io_total_write_kbs'] = tx/1024
             else:
                 config['io_read_kbs'] = 0.0
-                config['io_write_kbs'] = 0.0                
+                config['io_write_kbs'] = 0.0          
+                config['io_total_read_kbs'] = 0.0
+                config['io_total_write_kbs'] = 0.0
 
             config['security_label'] = config.get('security_label', '')
 
diff -r 2022cbc842af -r 94b3979606cd tools/python/xen/xend/XendMonitor.py
--- a/tools/python/xen/xend/XendMonitor.py      Tue Nov 20 15:13:29 2007 +0000
+++ b/tools/python/xen/xend/XendMonitor.py      Tue Nov 20 15:18:09 2007 +0000
@@ -63,6 +63,8 @@ class XendMonitor(threading.Thread):
     @type domain_vcpus_util: {domid: {vcpuid: float, vcpuid: float}}
     @ivar domain_vifs_util: Bytes per second for VIFs indexed by domain
     @type domain_vifs_util: {domid: {vifid: (rx_bps, tx_bps)}}
+    @ivar domain_vifs_stat: Total amount of bytes used for VIFs indexed by 
domain
+    @type domain_vifs_stat: {domid: {vbdid: (rx, tx)}}
     @ivar domain_vbds_util: Blocks per second for VBDs index by domain.
     @type domain_vbds_util: {domid: {vbdid: (rd_reqps, wr_reqps)}}    
     
@@ -83,6 +85,7 @@ class XendMonitor(threading.Thread):
         # instantaneous statistics
         self._domain_vcpus_util = {}
         self._domain_vifs_util = {}
+        self._domain_vifs_stat = {}
         self._domain_vbds_util = {}
         self.pifs_util = {}
 
@@ -104,6 +107,13 @@ class XendMonitor(threading.Thread):
         self.lock.acquire()
         try:
             return self._domain_vifs_util
+        finally:
+            self.lock.release()
+
+    def get_domain_vifs_stat(self):
+        self.lock.acquire()
+        try:
+            return self._domain_vifs_stat
         finally:
             self.lock.release()
 
@@ -269,6 +279,7 @@ class XendMonitor(threading.Thread):
                     if domid not in self._domain_vifs:
                         self._domain_vifs[domid] = vifs
                         self._domain_vifs_util[domid] = {}
+                        self._domain_vifs_stat[domid] = {}
                         continue
                 
                     for devid, (usage_at, rx, tx) in vifs.items():
@@ -286,6 +297,8 @@ class XendMonitor(threading.Thread):
                         # not the guest interface
                         self._domain_vifs_util[domid][devid] = \
                              (tx_util, rx_util)
+                        self._domain_vifs_stat[domid][devid] = \
+                             (float(tx), float(rx))
                         
                     self._domain_vifs[domid] = vifs
 
@@ -313,6 +326,7 @@ class XendMonitor(threading.Thread):
                     if domid not in active_domids:
                         del self._domain_vifs_util[domid]
                         del self._domain_vifs[domid]
+                        del self._domain_vifs_stat[domid]
                 for domid in self._domain_vbds_util.keys():
                     if domid not in active_domids:
                         del self._domain_vbds_util[domid]
diff -r 2022cbc842af -r 94b3979606cd tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Tue Nov 20 15:13:29 2007 +0000
+++ b/tools/python/xen/xend/XendNode.py Tue Nov 20 15:18:09 2007 +0000
@@ -651,6 +651,12 @@ class XendNode:
             return vif_loads[domid].get(vifid, (0.0, 0.0))
         return (0.0, 0.0)
 
+    def get_vif_stat(self, domid, vifid):
+        vif_loads = self.monitor.get_domain_vifs_stat()
+        if domid in vif_loads:
+            return vif_loads[domid].get(vifid, (0.0, 0.0))
+        return (0.0, 0.0)
+
     def get_vbd_util(self, domid, vbdid):
         vbd_loads = self.monitor.get_domain_vbds_util()
         if domid in vbd_loads:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.