ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12825 CPU metrics graph shows inconsistent info (dsen)
Date Thu, 20 Aug 2015 18:29:12 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1.1 abd1c5852 -> cc3647ef0


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/cc3647ef
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cc3647ef
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cc3647ef

Branch: refs/heads/branch-2.1.1
Commit: cc3647ef0f445c027733dc38e25d22f8a2f1c0bf
Parents: abd1c58
Author: Dmytro Sen <dsen@apache.org>
Authored: Thu Aug 20 21:25:56 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Thu Aug 20 21:29:04 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/cc3647ef/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()


Mime
View raw message