Browse Source

AMBARI-14658: Ambari Metrics service does not show data for swap_total memory metric(bhuvnesh2703 via jaoki)

Jun Aoki 9 years ago
parent
commit
9ab4b5e6f4

+ 2 - 0
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/host_info.py

@@ -109,6 +109,7 @@ class HostInfo():
     swap_stats = psutil.swap_memory()
     disk_usage = self.get_combined_disk_usage()
     mem_total = self.__host_static_info.get('mem_total')
+    swap_total = self.__host_static_info.get('swap_total')
 
     bytes2kilobytes = lambda x: x / 1024
 
@@ -120,6 +121,7 @@ class HostInfo():
       'mem_buffered': bytes2kilobytes(mem_stats.buffers) if hasattr(mem_stats, 'buffers') else 0,
       'mem_cached': bytes2kilobytes(mem_stats.cached) if hasattr(mem_stats, 'cached') else 0,
       'swap_free': bytes2kilobytes(swap_stats.free) if hasattr(swap_stats, 'free') else 0,
+      'swap_total': bytes2kilobytes(swap_total) if swap_total else 0,
       'disk_free' : disk_usage.get("disk_free"),
       # todo: cannot send string
       #'part_max_used' : disk_usage.get("max_part_used")[0],

+ 2 - 1
ambari-metrics/ambari-metrics-timelineservice/src/main/resources/metrics_def/HOST.dat

@@ -20,4 +20,5 @@ mem_free
 mem_shared
 pkts_in
 pkts_out
-swap_free
+swap_free
+swap_total

+ 2 - 1
ambari-metrics/ambari-metrics-timelineservice/src/test/resources/ui_metrics_def/HOST.dat

@@ -75,5 +75,6 @@ mem_shared
 mem_free
 cpu_nice
 swap_free
+swap_total
 pkts_out
-|hostname|startTime|endTime|
+|hostname|startTime|endTime|