debuggers.hg
changeset 16438:94b3979606cd
xenapi: Extension to get vif total i/o stats.
From: Stefan de Konink <skinkie@xs4all.nl>
Signed-off-by: Keir Fraser <keir.fraser@eu.citrix.com>
From: Stefan de Konink <skinkie@xs4all.nl>
Signed-off-by: Keir Fraser <keir.fraser@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Nov 20 15:18:09 2007 +0000 (2007-11-20) |
parents | 2022cbc842af |
children | f62e6c697eeb |
files | tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendMonitor.py tools/python/xen/xend/XendNode.py |
line diff
1.1 --- a/tools/python/xen/xend/XendAPI.py Tue Nov 20 15:13:29 2007 +0000 1.2 +++ b/tools/python/xen/xend/XendAPI.py Tue Nov 20 15:18:09 2007 +0000 1.3 @@ -2111,6 +2111,8 @@ class XendAPI(object): 1.4 1.5 VIF_metrics_attr_ro = ['io_read_kbs', 1.6 'io_write_kbs', 1.7 + 'io_total_read_kbs', 1.8 + 'io_total_write_kbs', 1.9 'last_updated'] 1.10 VIF_metrics_attr_rw = [] 1.11 VIF_metrics_methods = [] 1.12 @@ -2125,6 +2127,8 @@ class XendAPI(object): 1.13 return xen_api_success( 1.14 { 'io_read_kbs' : vm.get_dev_property('vif', ref, 'io_read_kbs'), 1.15 'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs'), 1.16 + 'io_total_read_kbs' : vm.get_dev_property('vif', ref, 'io_total_read_kbs'), 1.17 + 'io_total_write_kbs' : vm.get_dev_property('vif', ref, 'io_total_write_kbs'), 1.18 'last_updated' : now() 1.19 }) 1.20 1.21 @@ -2134,6 +2138,12 @@ class XendAPI(object): 1.22 def VIF_metrics_get_io_write_kbs(self, session, ref): 1.23 return self._VIF_get(ref, 'io_write_kbs') 1.24 1.25 + def VIF_metrics_get_io_total_read_kbs(self, _, ref): 1.26 + return self._VIF_get(ref, 'io_total_read_kbs') 1.27 + 1.28 + def VIF_metrics_get_io_total_write_kbs(self, session, ref): 1.29 + return self._VIF_get(ref, 'io_total_write_kbs') 1.30 + 1.31 def VIF_metrics_get_last_updated(self, _1, _2): 1.32 return xen_api_success(now()) 1.33
2.1 --- a/tools/python/xen/xend/XendDomainInfo.py Tue Nov 20 15:13:29 2007 +0000 2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Tue Nov 20 15:18:09 2007 +0000 2.3 @@ -2606,9 +2606,14 @@ class XendDomainInfo: 2.4 rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid) 2.5 config['io_read_kbs'] = rx_bps/1024 2.6 config['io_write_kbs'] = tx_bps/1024 2.7 + rx, tx = xennode.get_vif_stat(self.domid, devid) 2.8 + config['io_total_read_kbs'] = rx/1024 2.9 + config['io_total_write_kbs'] = tx/1024 2.10 else: 2.11 config['io_read_kbs'] = 0.0 2.12 - config['io_write_kbs'] = 0.0 2.13 + config['io_write_kbs'] = 0.0 2.14 + config['io_total_read_kbs'] = 0.0 2.15 + config['io_total_write_kbs'] = 0.0 2.16 2.17 config['security_label'] = config.get('security_label', '') 2.18
3.1 --- a/tools/python/xen/xend/XendMonitor.py Tue Nov 20 15:13:29 2007 +0000 3.2 +++ b/tools/python/xen/xend/XendMonitor.py Tue Nov 20 15:18:09 2007 +0000 3.3 @@ -63,6 +63,8 @@ class XendMonitor(threading.Thread): 3.4 @type domain_vcpus_util: {domid: {vcpuid: float, vcpuid: float}} 3.5 @ivar domain_vifs_util: Bytes per second for VIFs indexed by domain 3.6 @type domain_vifs_util: {domid: {vifid: (rx_bps, tx_bps)}} 3.7 + @ivar domain_vifs_stat: Total amount of bytes used for VIFs indexed by domain 3.8 + @type domain_vifs_stat: {domid: {vbdid: (rx, tx)}} 3.9 @ivar domain_vbds_util: Blocks per second for VBDs index by domain. 3.10 @type domain_vbds_util: {domid: {vbdid: (rd_reqps, wr_reqps)}} 3.11 3.12 @@ -83,6 +85,7 @@ class XendMonitor(threading.Thread): 3.13 # instantaneous statistics 3.14 self._domain_vcpus_util = {} 3.15 self._domain_vifs_util = {} 3.16 + self._domain_vifs_stat = {} 3.17 self._domain_vbds_util = {} 3.18 self.pifs_util = {} 3.19 3.20 @@ -107,6 +110,13 @@ class XendMonitor(threading.Thread): 3.21 finally: 3.22 self.lock.release() 3.23 3.24 + def get_domain_vifs_stat(self): 3.25 + self.lock.acquire() 3.26 + try: 3.27 + return self._domain_vifs_stat 3.28 + finally: 3.29 + self.lock.release() 3.30 + 3.31 def get_pifs_util(self): 3.32 self.lock.acquire() 3.33 try: 3.34 @@ -269,6 +279,7 @@ class XendMonitor(threading.Thread): 3.35 if domid not in self._domain_vifs: 3.36 self._domain_vifs[domid] = vifs 3.37 self._domain_vifs_util[domid] = {} 3.38 + self._domain_vifs_stat[domid] = {} 3.39 continue 3.40 3.41 for devid, (usage_at, rx, tx) in vifs.items(): 3.42 @@ -286,6 +297,8 @@ class XendMonitor(threading.Thread): 3.43 # not the guest interface 3.44 self._domain_vifs_util[domid][devid] = \ 3.45 (tx_util, rx_util) 3.46 + self._domain_vifs_stat[domid][devid] = \ 3.47 + (float(tx), float(rx)) 3.48 3.49 self._domain_vifs[domid] = vifs 3.50 3.51 @@ -313,6 +326,7 @@ class XendMonitor(threading.Thread): 3.52 if domid not in active_domids: 3.53 del self._domain_vifs_util[domid] 3.54 del self._domain_vifs[domid] 3.55 + del self._domain_vifs_stat[domid] 3.56 for domid in self._domain_vbds_util.keys(): 3.57 if domid not in active_domids: 3.58 del self._domain_vbds_util[domid]
4.1 --- a/tools/python/xen/xend/XendNode.py Tue Nov 20 15:13:29 2007 +0000 4.2 +++ b/tools/python/xen/xend/XendNode.py Tue Nov 20 15:18:09 2007 +0000 4.3 @@ -651,6 +651,12 @@ class XendNode: 4.4 return vif_loads[domid].get(vifid, (0.0, 0.0)) 4.5 return (0.0, 0.0) 4.6 4.7 + def get_vif_stat(self, domid, vifid): 4.8 + vif_loads = self.monitor.get_domain_vifs_stat() 4.9 + if domid in vif_loads: 4.10 + return vif_loads[domid].get(vifid, (0.0, 0.0)) 4.11 + return (0.0, 0.0) 4.12 + 4.13 def get_vbd_util(self, domid, vbdid): 4.14 vbd_loads = self.monitor.get_domain_vbds_util() 4.15 if domid in vbd_loads: