-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Stefan de Konink schreef:
> Stefan de Konink schreef:
>> Now I get the read_io and write_io, I honestly was looking for the total
>> amount of bytes received/sent. Would it be accepted if this was
>> implemented in the VIF_metrics?
>
> It is interesting to respond to myself, but in Xen Unstable I have found
> the vif_stats implementation, so I'll give it a try.
Here is an extension to the XenAPI. It is probably useful in other
situations too, such as on the Physical Interface. This extension
implements total statistics on the virtual interface of a domain. Useful
when you want to fill RRD files per domain, from the XenAPI.
It is a patch against 3.1.2. Unstable looks the same. So I guess it
should work there too.
Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHPpgaYH1+F2Rqwn0RCs4MAJwMm8jxG0QXMtPTpp75iu8rpT+z/wCeLPq2
uOyuQRXgBO6rxbxiLPZmlGs=
=3di/
-----END PGP SIGNATURE-----
--- /usr/src/xen-3.1.2/tools/python/xen/xend/XendDomainInfo.py 2007-11-15
00:35:27.000000000 +0100
+++ XendDomainInfo.py 2007-11-17 09:15:46.000000000 +0100
@@ -2383,9 +2383,14 @@
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
if dev_class == 'vbd':
--- /usr/src/xen-3.1.2/tools/python/xen/xend/XendAPI.py 2007-11-15
00:35:27.000000000 +0100
+++ XendAPI.py 2007-11-17 08:42:45.000000000 +0100
@@ -2060,6 +2060,8 @@
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 = []
@@ -2074,6 +2076,8 @@
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()
})
@@ -2083,6 +2087,12 @@
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())
--- /usr/src/xen-3.1.2/tools/python/xen/xend/XendMonitor.py 2007-11-15
00:35:27.000000000 +0100
+++ XendMonitor.py 2007-11-17 09:16:54.000000000 +0100
@@ -63,6 +63,8 @@
@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 @@
# instantaneous statistics
self._domain_vcpus_util = {}
self._domain_vifs_util = {}
+ self._domain_vifs_stat = {}
self._domain_vbds_util = {}
self.pifs_util = {}
@@ -107,6 +110,13 @@
finally:
self.lock.release()
+ def get_domain_vifs_stat(self):
+ self.lock.acquire()
+ try:
+ return self._domain_vifs_stat
+ finally:
+ self.lock.release()
+
def get_pifs_util(self):
self.lock.acquire()
try:
@@ -269,6 +279,7 @@
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 @@
# 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 @@
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]
--- /usr/src/xen-3.1.2/tools/python/xen/xend/XendNode.py 2007-11-15
00:35:27.000000000 +0100
+++ XendNode.py 2007-11-17 08:45:16.000000000 +0100
@@ -607,6 +607,12 @@
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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|