Change in vdsm[master]: sampling: hoststats: rationalize getInterfaceStats

fromani at redhat.com fromani at redhat.com
Thu Apr 30 08:48:47 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: sampling: hoststats: rationalize getInterfaceStats
......................................................................

sampling: hoststats: rationalize getInterfaceStats

HostStatsThread._getInterfaceStats() is supposed
to gather network stats.

But this method also setups the empty stats with
default value.
This initialization doesn't belong here, so this
patch moves this code outside this method, in the
calling one.

Change-Id: I556149271fb2786a6ff7341642989ea767eb2392
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 16 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/40426/1

diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 7349b9f..710bba9 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -604,13 +604,25 @@
             return None
 
     def get(self):
-        stats = self._getInterfacesStats()
-        stats['cpuSysVdsmd'] = stats['cpuUserVdsmd'] = 0.0
-        stats['elapsedTime'] = int(time.time() - self.startTime)
+        stats = {
+            'cpuUser': 0.0,
+            'cpuSys': 0.0,
+            'cpuIdle': 100.0,
+            'rxRate': 0.0,
+            'txRate': 0.0,
+            'cpuSysVdsmd': 0.0,
+            'cpuUserVdsmd': 0.0,
+            'elapsedTime': int(time.time() - self.startTime)
+        }
+
         if len(self._samples) < 2:
             return stats
+
+        stats.update(self._getInterfacesStats())
+
         hs0, hs1 = self._samples[0], self._samples[-1]
         interval = hs1.timestamp - hs0.timestamp
+
         jiffies = (hs1.pidcpu.user - hs0.pidcpu.user) % (2 ** 32)
         stats['cpuUserVdsmd'] = jiffies / interval
         jiffies = (hs1.pidcpu.sys - hs0.pidcpu.sys) % (2 ** 32)
@@ -680,8 +692,7 @@
             * rxRate
             * txRate
         """
-        stats = {'cpuUser': 0.0, 'cpuSys': 0.0, 'cpuIdle': 100.0,
-                 'rxRate': 0.0, 'txRate': 0.0}
+        stats = {}
         if len(self._samples) < 2:
             return stats
         hs0, hs1 = self._samples[0], self._samples[-1]


-- 
To view, visit https://gerrit.ovirt.org/40426
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I556149271fb2786a6ff7341642989ea767eb2392
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list