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

[Xen-API] [Fwd: [Xen-devel] XenAPI extention with VIF stats]


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Stefan de Konink <skinkie@xxxxxxxxx>
  • Date: Tue, 20 Nov 2007 01:12:39 +0100
  • Delivery-date: Mon, 19 Nov 2007 16:15:17 -0800
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Already posted the following to the Xen-Devel list. Maybe this is more
appropriate for discussion. Currently I'm working on several Xen
extensions relating to the XenAPI (for monitoring) en the config scheme
to support more out of the box behavior.

I would like to have a way to run a command on the Dom0 machine, using
the API. Is there anyone already doing so?


Next to this I would like to implement iscsi:// as blockdevice, so a
Dom0 automatically does a login and logout upop create/migrate and
shutdown/migrate.


If possible I would like to put my patches somewhere, if this
mailinglist is *the* place, I'm happy to do so.

- -------- Originele bericht --------

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

iD8DBQFHQiZ3YH1+F2Rqwn0RCjxeAJ0c+A7HGF2BjlBvMo4fVhPoeYc4CQCgjAdl
i6hQfA/t8qhtgiXr6ELgkN8=
=t4lF
-----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-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-api

 


Rackspace

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