WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XEND] Hook in utilisation statistics int

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEND] Hook in utilisation statistics into Xen API calls.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 27 Jan 2007 13:00:24 -0800
Delivery-date: Sat, 27 Jan 2007 13:01:29 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Date 1169826351 0
# Node ID b97780b7080dd61abcdbad166d999fde7fe49d16
# Parent  93d3ff513609694b40b802579a94963fd112b4fc
[XEND] Hook in utilisation statistics into Xen API calls.

Change PIF to be indexed by device name rather than the interface
number.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py     |   19 ++++++++++++++-----
 tools/python/xen/xend/XendMonitor.py |   18 +++++++++---------
 tools/python/xen/xend/XendNode.py    |    6 +++---
 tools/python/xen/xend/XendPIF.py     |    6 ++++--
 4 files changed, 30 insertions(+), 19 deletions(-)

diff -r 93d3ff513609 -r b97780b7080d tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Fri Jan 26 15:44:41 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Fri Jan 26 15:45:51 2007 +0000
@@ -1448,10 +1448,15 @@ class XendAPI(object):
                                                               'type'))        
 
     def VBD_get_io_read_kbs(self, session, vbd_ref):
-        return xen_api_todo()
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
+                                                              'io_read_kbs'))
+    
     
     def VBD_get_io_write_kbs(self, session, vbd_ref):
-        return xen_api_todo()
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
+                                                              'io_read_kbs'))
     
     def VBD_get_all(self, session):
         xendom = XendDomain.instance()
@@ -1553,10 +1558,14 @@ class XendAPI(object):
     
  
     def VIF_get_io_read_kbs(self, session, vif_ref):
-        return xen_api_todo()
-    
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
+                                                               'io_read_kbs'))
+
     def VIF_get_io_write_kbs(self, session, vif_ref):
-        return xen_api_todo()
+        xendom = XendDomain.instance()
+        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
+                                                               'io_write_kbs'))
     
     def VIF_get_all(self, session):
         xendom = XendDomain.instance()
diff -r 93d3ff513609 -r b97780b7080d tools/python/xen/xend/XendMonitor.py
--- a/tools/python/xen/xend/XendMonitor.py      Fri Jan 26 15:44:41 2007 +0000
+++ b/tools/python/xen/xend/XendMonitor.py      Fri Jan 26 15:45:51 2007 +0000
@@ -49,7 +49,7 @@ PROC_NET_DEV_RE = r'(?P<rx_bytes>\d+)\s+
 
 VIF_DOMAIN_RE = re.compile(r'vif(?P<domid>\d+)\.(?P<iface>\d+):\s*' +
                            PROC_NET_DEV_RE)
-PIF_RE = re.compile(r'peth(?P<iface>\d+):\s*' + PROC_NET_DEV_RE)
+PIF_RE = re.compile(r'^\s*(?P<iface>peth\d+):\s*' + PROC_NET_DEV_RE)
 
 # The VBD transfer figures are in "requests" where we don't
 # really know how many bytes per requests. For now we make
@@ -154,10 +154,10 @@ class XendMonitor(threading.Thread):
             if not is_pif:
                 continue
             
-            pifid = int(is_pif.group('iface'))
+            pifname = is_pif.group('iface')
             rx_bytes = int(is_pif.group('rx_bytes'))
             tx_bytes = int(is_pif.group('tx_bytes'))
-            stats[pifid] = (usage_at, rx_bytes, tx_bytes)
+            stats[pifname] = (usage_at, rx_bytes, tx_bytes)
 
         return stats    
 
@@ -297,19 +297,19 @@ class XendMonitor(threading.Thread):
 
                 # Calculate utilisation for PIFs
 
-                for pifid, stats in self._get_pif_stats().items():
-                    if pifid not in self.pifs:
-                        self.pifs[pifid] = stats
+                for pifname, stats in self._get_pif_stats().items():
+                    if pifname not in self.pifs:
+                        self.pifs[pifname] = stats
                         continue
 
                     usage_at, rx, tx = stats
-                    prv_at, prv_rx, prv_tx  = self.pifs[pifid]
+                    prv_at, prv_rx, prv_tx  = self.pifs[pifname]
                     interval = usage_at - prv_at
                     rx_util = (rx - prv_rx)/interval
                     tx_util = (tx - prv_tx)/interval
 
-                    self.pifs_util[pifid] = (rx_util, tx_util)
-                    self.pifs[pifid] = stats
+                    self.pifs_util[pifname] = (rx_util, tx_util)
+                    self.pifs[pifname] = stats
 
                 for domid in self._domain_vcpus_util.keys():
                     if domid not in active_domids:
diff -r 93d3ff513609 -r b97780b7080d tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Fri Jan 26 15:44:41 2007 +0000
+++ b/tools/python/xen/xend/XendNode.py Fri Jan 26 15:45:51 2007 +0000
@@ -482,10 +482,10 @@ class XendNode:
             return vbd_loads[domid].get(vbdid, (0.0, 0.0))
         return (0.0, 0.0)
 
-    def get_pif_util(self, pifid):
+    def get_pif_util(self, pifname):
         pifs_util = self.monitor.get_pifs_util()
-        if pifid in pifs_util:
-            return pifs_util[pifid]
+        if pifname in pifs_util:
+            return pifs_util[pifname]
         return (0.0, 0.0)
 
     # dictionary version of *info() functions to get rid of
diff -r 93d3ff513609 -r b97780b7080d tools/python/xen/xend/XendPIF.py
--- a/tools/python/xen/xend/XendPIF.py  Fri Jan 26 15:44:41 2007 +0000
+++ b/tools/python/xen/xend/XendPIF.py  Fri Jan 26 15:45:51 2007 +0000
@@ -115,10 +115,12 @@ class XendPIF:
         return success
 
     def get_io_read_kbs(self):
-        return 0.0
+        from xen.xend.XendNode import instance as xennode
+        return xennode().get_pif_util(self.name)[0]
 
     def get_io_write_kbs(self):
-        return 0.0
+        from xen.xend.XendNode import instance as xennode
+        return xennode().get_pif_util(self.name)[1]      
 
     def get_record(self, transient = True):
         result = {'name': self.name,

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEND] Hook in utilisation statistics into Xen API calls., Xen patchbot-unstable <=