Change in vdsm[master]: net stats: drop statsAge from statistics

danken at redhat.com danken at redhat.com
Tue Dec 30 16:44:26 UTC 2014


Dan Kenigsberg has uploaded a new change for review.

Change subject: net stats: drop statsAge from statistics
......................................................................

net stats: drop statsAge from statistics

statsAge has been reported by getVdsStats and getAllVmStats since ever,
but it has never been consumed by Engine. This patch drops this element,
since we would like to report sampleTime in a following patch, and would
not like to report duplicate information.

Change-Id: I3f48e2eecc49bdf877056295b198725add1f792d
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
3 files changed, 7 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/36482/1

diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 65a6302..e1849e1 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -1955,8 +1955,6 @@
 #
 # @txRate:          Outgoing packet rate (as a percentage of total capacity)
 #
-# @statsAge:        Seconds elapsed since the stats were last sampled
-#
 # @network:         Per-interface network statistics
 #
 # @rxDropped:       The number of incoming packets dropped
@@ -2033,7 +2031,7 @@
 ##
 {'type': 'HostStats',
  'data': {'cpuUser': 'float', 'cpuSys': 'float', 'cpuIdle': 'float',
-           'rxRate': 'float', 'txRate': 'float', 'statsAge': 'uint',
+           'rxRate': 'float', 'txRate': 'float',
            'network': 'HostNetworkInterfaceStatsMap',
            'rxDropped': 'uint', 'txDropped': 'uint',
            'cpuSysVdsmd': 'float', 'cpuUserVdsmd': 'float',
@@ -6723,8 +6721,6 @@
 #
 # @boot: #optional     An alias for the type of device used to boot the VM
 #
-# @statsAge:           The age of these statistics in seconds
-#
 # @cpuSys:             Ratio of CPU time spent by qemu on other than guest time
 #
 # @cpuUser:            Ratio of CPU time spent by the guest VM
@@ -6801,7 +6797,7 @@
           'network': 'NetworkInterfaceStatsMap',
           'disks': 'VmDiskStatsMap', 'monitorResponse': 'int',
           'elapsedTime': 'uint', '*cdrom': 'str',
-          '*boot': 'VmBootMode','statsAge': 'float', 'cpuSys': 'float',
+          '*boot': 'VmBootMode', 'cpuSys': 'float',
           'cpuUser': 'float',
           'acpiEnable': 'bool', 'timeOffset': 'uint',
           'clientIp': 'str', 'pauseCode': 'str', 'memUsage': 'uint',
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 04203ff..86071c6 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -527,7 +527,6 @@
         self._log = log
         self._stopEvent = threading.Event()
         self._samples = []
-        self._lastSampleTime = time.time()
 
         self._pid = os.getpid()
         self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1)
@@ -555,7 +554,6 @@
                         if diff:
                             self._CONNLOG.debug('%s', diff)
 
-                    self._lastSampleTime = sample.timestamp
                     if len(self._samples) > self.AVERAGING_WINDOW:
                         self._samples.pop(0)
                 except vm.TimeoutError:
@@ -651,8 +649,7 @@
             * txRate
         """
         stats = {'cpuUser': 0.0, 'cpuSys': 0.0, 'cpuIdle': 100.0,
-                 'rxRate': 0.0, 'txRate': 0.0,
-                 'statsAge': time.time() - self._lastSampleTime}
+                 'rxRate': 0.0, 'txRate': 0.0, }
         if len(self._samples) < 2:
             return stats
         hs0, hs1 = self._samples[0], self._samples[-1]
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6617526..767f9b9 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -665,12 +665,6 @@
     def get(self):
         stats = {}
 
-        try:
-            stats['statsAge'] = time.time() - self.getLastSampleTime()
-        except TypeError:
-            self._log.debug("Stats age not available")
-            stats['statsAge'] = -1.0
-
         self._getCpuStats(stats)
         self._getNetworkStats(stats)
         self._getDiskStats(stats)
@@ -2341,9 +2335,11 @@
 
         decStats = {}
         try:
-            if self._vmStats:
+            if self._vmStats and self._vmStats.getLastSampleTime() is not None:
                 decStats = self._vmStats.get()
-                self._setUnresponsiveIfTimeout(stats, decStats['statsAge'])
+                self._setUnresponsiveIfTimeout(
+                    stats,
+                    time.time() - self._vmStats.getLastSampleTime())
         except Exception:
             self.log.exception("Error fetching vm stats")
         for var in decStats:


-- 
To view, visit http://gerrit.ovirt.org/36482
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f48e2eecc49bdf877056295b198725add1f792d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list