Skip to contentSkip to conversation

VIF_metrics = 0

DISCUSSION Stefan de Konink 1 participant 4 messages Nov 17, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

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

Hi,

I use the following code snippet based on xapi.py to request the metrics of the DomU's.

Quoted 4 lines

def request_vif_metrics():
server, session = connect()
vm_uuids = execute(server, 'VM.get_all', (session,))

Quoted 12 lines

for uuid in vm_uuids:
vm_info = execute(server, 'VM.get_record', (session, uuid))
vifs = vm_info['VIFs']
read = 0.0;
write = 0.0;
for vif in vifs:
vif_metrics = execute(server, 'VIF.get_metrics', (session, vif)) vif_metrics_struct = execute(server, 'VIF_metrics.get_record', (session, vif_metrics)) print vif_metrics_struct
read += vif_metrics_struct['io_read_kbs']
write += vif_metrics_struct['io_write_kbs']
print '%s: %f %f' % (vm_info['name_label'], read, write)

I would expect to get some numbers higher than 0.0 from the vif_metrics_struct.

The actual output:

Domain-0: 0.000000 0.000000
{'io_read_kbs': 0.0, 'last_updated': <DateTime '20071117T03:01:10' at 808e60>, 'io_write_kbs': 0.0}
skinkie_gentoo_old: 0.000000 0.000000
{'io_read_kbs': 0.0, 'last_updated': <DateTime '20071117T03:01:10' at 808908>, 'io_write_kbs': 0.0}
gameserver01: 0.000000 0.000000

I'm running Xen-tools 3.1.1, am I running an older version, or is this a bug?

Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHPkxUYH1+F2Rqwn0RCjPSAJ479OCLZG+BUUI1c9jYl34roerpmwCeIuhc uGeBRULLsd3pWuOtynnapZI=
=vBew
-----END PGP SIGNATURE-----

#1 lore raw

Re: VIF_metrics = 0 [workaround] -> Feature request

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

Stefan de Konink schreef:

Quoted 2 lines

I would expect to get some numbers higher than 0.0 from the vif_metrics_struct.

Problem occurs when a vifname is given for the virtual interface. As in Bug 1111.

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?

Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHPn49YH1+F2Rqwn0RCoN+AJ9bQ0RmLDPjsCzeNsX9chE/lwIHhwCfTOoQ Z+uiv/qy3ql4T7+WuFQ8h/Q=
=CucA
-----END PGP SIGNATURE-----

#2 lore raw

Re: VIF_metrics = 0 [workaround] -> Feature request [in unstable]

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

Stefan de Konink schreef:

Quoted 3 lines

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.

Stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHPoAnYH1+F2Rqwn0RCj5iAKCKbnFo1/tKRiqLYehmRcHZ8K8X5ACfV4Gn fhsVam+DWC4fRHv9/zRCSD0=
=aM9B
-----END PGP SIGNATURE-----

#3 lore raw

XenAPI extention with VIF stats

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

Stefan de Konink schreef:

Quoted 7 lines

Stefan de Konink schreef:

Quoted 3 lines

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-----

XendDomainInfo.py renamed from usr/src/xen-3.1.2/tools/python/xen/xend/XendDomainInfo.py +6 -1
@@ -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':
 
XendAPI.py renamed from usr/src/xen-3.1.2/tools/python/xen/xend/XendAPI.py +10 -0
@@ -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())
 
XendMonitor.py renamed from usr/src/xen-3.1.2/tools/python/xen/xend/XendMonitor.py +14 -0
@@ -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]
XendNode.py renamed from usr/src/xen-3.1.2/tools/python/xen/xend/XendNode.py +6 -0
@@ -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
[email protected]
http://lists.xensource.com/xen-devel