You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by av...@apache.org on 2016/10/26 23:56:14 UTC

ambari git commit: AMBARI-18705 : All host metrics not being collected by AMS if user does not have permissions to read mount point. (avijayan)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 5eefb316e -> 53331906f


AMBARI-18705 : All host metrics not being collected by AMS if user does not have permissions to read mount point. (avijayan)


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

Branch: refs/heads/branch-2.4
Commit: 53331906fe9c54ced9df4bbb562846d7b9a99e75
Parents: 5eefb31
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Wed Oct 26 16:56:07 2016 -0700
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Wed Oct 26 16:56:07 2016 -0700

----------------------------------------------------------------------
 .../src/main/python/core/host_info.py                   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/53331906/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 845b270..400cc79 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
@@ -176,6 +176,7 @@ class HostInfo():
     max_percent_usage = ('', 0)
 
     partition_count = 0
+    devices = set()
     for part in psutil.disk_partitions(all=False):
       if os.name == 'nt':
         if 'cdrom' in part.opts or part.fstype == '':
@@ -185,8 +186,15 @@ class HostInfo():
           continue
         pass
       pass
-      usage = psutil.disk_usage(part.mountpoint)
-
+      try:
+        usage = psutil.disk_usage(part.mountpoint)
+      except Exception, e:
+        logger.error('Failed to read disk_usage for a mountpoint : ' + str(e))
+        continue
+
+      if part.device in devices: # Skip devices already seen.
+        continue
+      devices.add(part.device)
       combined_disk_total += usage.total if hasattr(usage, 'total') else 0
       combined_disk_used += usage.used if hasattr(usage, 'used') else 0
       combined_disk_free += usage.free if hasattr(usage, 'free') else 0