Yaniv Bronhaim has uploaded a new change for review.

Change subject: Adding reportStats
......................................................................

Adding reportStats

Adding function that uses statsd to report internal host info. This will
be called after each sampling for now.

Change-Id: I23c1141f097f740441d085f99e0bf76eb7f718c9
Signed-off-by: Yaniv Bronhaim <[email protected]>
---
M lib/vdsm/host.py
M lib/vdsm/virt/sampling.py
2 files changed, 25 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/56880/1

diff --git a/lib/vdsm/host.py b/lib/vdsm/host.py
index 0752663..6578872 100644
--- a/lib/vdsm/host.py
+++ b/lib/vdsm/host.py
@@ -24,6 +24,7 @@
 import logging
 import os
 import six
+import statsd
 import time
 from vdsm import cpuarch
 from vdsm import hooks
@@ -42,6 +43,7 @@
 
 _clock = utils.monotonic_time
 _start_time = 0
+_current_stats = {}
 
 
 def _elapsed_time():
@@ -408,6 +410,8 @@
     """
     Retreive host internal statistics
     """
+    global _current_stats
+
     hooks.before_get_stats()
     stats = {}
 
@@ -443,4 +447,23 @@
         stats['haScore'] = stats['haStats']['score']
 
     stats = hooks.after_get_stats(stats)
+    _current_stats = stats
     return stats
+
+
+def reportStats():
+    """
+    Send gauge values to statsd
+    The format
+    """
+    report = statsd.Gauge(".host." + uuid())
+    report.send('memAvailable', _current_stats['memAvailable'])
+    report.send('memCommitted', _current_stats['memCommitted'])
+    report.send('memFree', _current_stats['memFree'])
+    report.send('swapTotal', _current_stats['swapTotal'])
+    report.send('swapFree', _current_stats['swapFree'])
+    report.send('vmActive', _current_stats['vmActive'])
+    report.send('vmCount', _current_stats['vmCount'])
+    report.send('vmMigrating', _current_stats['vmMigrating'])
+    report.send('incomingVmMigrations', _current_stats['incomingVmMigrations'])
+    report.send('outgoingVmMigrations', _current_stats['outgoingVmMigrations'])
diff --git a/lib/vdsm/virt/sampling.py b/lib/vdsm/virt/sampling.py
index 5801099..74b0ef3 100644
--- a/lib/vdsm/virt/sampling.py
+++ b/lib/vdsm/virt/sampling.py
@@ -32,6 +32,7 @@
 import time
 
 from vdsm.constants import P_VDSM_RUN, P_VDSM_CLIENT_LOG
+from vdsm import host
 from vdsm import ipwrapper
 from vdsm import numa
 from vdsm.netinfo import nics, bonding, vlans
@@ -547,6 +548,7 @@
         sample = HostSample(self._pid)
         self._samples.append(sample)
         second_last = self._samples.last(nth=2)
+        host.reportStats()
         if second_last is None:
             self._CONNLOG.debug('%s', sample.to_connlog())
         else:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23c1141f097f740441d085f99e0bf76eb7f718c9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to