You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/08/20 20:23:57 UTC

ambari git commit: AMBARI-12825 CPU metrics graph shows inconsistent info (dsen)

Repository: ambari
Updated Branches:
  refs/heads/trunk 0bfb1ccf3 -> df98f0b53


AMBARI-12825 CPU metrics graph shows inconsistent info (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/df98f0b5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/df98f0b5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/df98f0b5

Branch: refs/heads/trunk
Commit: df98f0b53c3f78fb9f9e0b82eab77d7131e5a623
Parents: 0bfb1cc
Author: Dmytro Sen <ds...@apache.org>
Authored: Thu Aug 20 20:54:45 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Thu Aug 20 21:23:23 2015 +0300

----------------------------------------------------------------------
 .../src/main/python/core/host_info.py            | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/df98f0b5/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
index 826cd40..e0ed8e7 100644
--- a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
+++ b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py
@@ -55,19 +55,16 @@ class HostInfo():
     cpu_times = psutil.cpu_times_percent()
     cpu_count = self.__host_static_info.get('cpu_num', 1)
 
-    # Divide by number of cpu's on the system
-    number2percents = lambda x: ((x / int(cpu_count)) * 100)
-
     result = {
       'cpu_num': int(cpu_count),
-      'cpu_user': number2percents(cpu_times.user) if hasattr(cpu_times, 'user') else 0,
-      'cpu_system': number2percents(cpu_times.system) if hasattr(cpu_times, 'system') else 0,
-      'cpu_idle': number2percents(cpu_times.idle) if hasattr(cpu_times, 'idle') else 0,
-      'cpu_nice': number2percents(cpu_times.nice) if hasattr(cpu_times, 'nice') else 0,
-      'cpu_wio': number2percents(cpu_times.iowait) if hasattr(cpu_times, 'iowait') else 0,
-      'cpu_intr': number2percents(cpu_times.irq) if hasattr(cpu_times, 'irq') else 0,
-      'cpu_sintr': number2percents(cpu_times.softirq) if hasattr(cpu_times, 'softirq') else 0,
-      'cpu_steal': number2percents(cpu_times.steal) if hasattr(cpu_times, 'steal') else 0
+      'cpu_user': cpu_times.user*100 if hasattr(cpu_times, 'user') else 0,
+      'cpu_system': cpu_times.system*100 if hasattr(cpu_times, 'system') else 0,
+      'cpu_idle': cpu_times.idle*100 if hasattr(cpu_times, 'idle') else 0,
+      'cpu_nice': cpu_times.nice*100 if hasattr(cpu_times, 'nice') else 0,
+      'cpu_wio': cpu_times.iowait*100 if hasattr(cpu_times, 'iowait') else 0,
+      'cpu_intr': cpu_times.irq*100 if hasattr(cpu_times, 'irq') else 0,
+      'cpu_sintr': cpu_times.softirq*100 if hasattr(cpu_times, 'softirq') else 0,
+      'cpu_steal': cpu_times.steal*100 if hasattr(cpu_times, 'steal') else 0
     }
     if platform.system() != "Windows":
       load_avg = os.getloadavg()