Browse Source

AMBARI-17600. System boottime metric is not being collected by AMS. (swagle)

Siddharth Wagle 9 years ago
parent
commit
be18a92c98

+ 5 - 1
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py

@@ -53,6 +53,9 @@ class HostInfo():
     """
     cpu_times = psutil.cpu_times_percent()
     cpu_count = self.__host_static_info.get('cpu_num', 1)
+    # Since only boot time which is a part of static info is not sent with
+    # other payload sending it with cpu stats.
+    boot_time = self.__host_static_info.get('boot_time')
 
     result = {
       'cpu_num': int(cpu_count),
@@ -63,7 +66,8 @@ class HostInfo():
       'cpu_wio': cpu_times.iowait if hasattr(cpu_times, 'iowait') else 0,
       'cpu_intr': cpu_times.irq if hasattr(cpu_times, 'irq') else 0,
       'cpu_sintr': cpu_times.softirq if hasattr(cpu_times, 'softirq') else 0,
-      'cpu_steal': cpu_times.steal if hasattr(cpu_times, 'steal') else 0
+      'cpu_steal': cpu_times.steal if hasattr(cpu_times, 'steal') else 0,
+      'boot_time': long(boot_time) if boot_time else 0
     }
     if platform.system() != "Windows":
       load_avg = os.getloadavg()