Hello Piotr Kliczewski, Nir Soffer, Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/59775

to review the following change.

Change subject: Adding report_stats to health reports
......................................................................

Adding report_stats to health reports

Adding function that use reports.send function to report internal vdsm
usages (by health module which is tuned in vdsm.conf)

Change-Id: I885720b0b70620469c985d0079c4cbe9da74edf6
Signed-off-by: Yaniv Bronhaim <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/59065
Reviewed-by: Nir Soffer <[email protected]>
Reviewed-by: Francesco Romani <[email protected]>
Reviewed-by: Piotr Kliczewski <[email protected]>
Continuous-Integration: Jenkins CI
---
M lib/vdsm/health.py
1 file changed, 26 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/59775/1

diff --git a/lib/vdsm/health.py b/lib/vdsm/health.py
index 8e50a7f..85dcbc6 100644
--- a/lib/vdsm/health.py
+++ b/lib/vdsm/health.py
@@ -27,6 +27,8 @@
 from . config import config
 from . import concurrent
 from . import cpuarch
+from . import reports
+from . import host
 
 _monitor = None
 
@@ -56,6 +58,7 @@
         self._thread = concurrent.thread(self._run)
         self._done = threading.Event()
         self._last = ProcStat()
+        self._stats = {}
 
     def start(self):
         self.log.info("Starting health monitor (interval=%d)", self._interval)
@@ -87,6 +90,7 @@
         self.log.debug("Checking health")
         self._check_garbage()
         self._check_resources()
+        self._report_stats()
 
     def _check_garbage(self):
         collected = gc.collect()
@@ -97,20 +101,36 @@
             uncollectable = [saferepr(obj) for obj in uncollectable]
             self.log.warning("Found %d uncollectable objects: %s",
                              len(uncollectable), uncollectable)
+        self._stats['uncollectable_obj'] = len(uncollectable)
 
     def _check_resources(self):
         current = ProcStat()
-        utime_pct = (current.utime - self._last.utime) / self._interval * 100
-        stime_pct = (current.stime - self._last.stime) / self._interval * 100
+        self._stats['utime_pct'] = ((current.utime - self._last.utime) /
+                                    self._interval * 100)
+        self._stats['stime_pct'] = ((current.stime - self._last.stime) /
+                                    self._interval * 100)
+        self._stats['rss'] = current.rss
         delta_rss = current.rss - self._last.rss
+        self._stats['threads'] = current.threads
         self._last = current
         self.log.debug("user=%.2f%%, sys=%.2f%%, rss=%d kB (%s%d), threads=%d",
-                       utime_pct,
-                       stime_pct,
-                       current.rss,
+                       self._stats['utime_pct'],
+                       self._stats['stime_pct'],
+                       self._stats['rss'],
                        "+" if delta_rss >= 0 else "-",
                        abs(delta_rss),
-                       current.threads)
+                       self._stats['threads'])
+
+    def _report_stats(self):
+        prefix = "hosts." + host.uuid() + ".vdsm"
+        report = {}
+        report[prefix + '.gc.uncollectable'] = \
+            self._stats['uncollectable_obj']
+        report[prefix + '.cpu.user_pct'] = self._stats['utime_pct']
+        report[prefix + '.cpu.sys_pct'] = self._stats['stime_pct']
+        report[prefix + '.memory.rss'] = self._stats['rss']
+        report[prefix + '.threads_count'] = self._stats['threads']
+        reports.send(report)
 
 
 class ProcStat(object):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I885720b0b70620469c985d0079c4cbe9da74edf6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Yaniv Bronhaim <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Piotr Kliczewski <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to