]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: Expose OSD Flags
authorBoris Ranto <branto@redhat.com>
Sat, 17 Feb 2018 03:45:01 +0000 (04:45 +0100)
committerBoris Ranto <branto@redhat.com>
Tue, 3 Apr 2018 16:35:14 +0000 (18:35 +0200)
Signed-off-by: Boris Ranto <branto@redhat.com>
src/pybind/mgr/prometheus/module.py

index 3770a7202dad0452355d317930c2fc95a696eb43..a90154bcf3be5c89a982e156ceda8df628ea2ded 100644 (file)
@@ -52,6 +52,9 @@ DF_CLUSTER = ['total_bytes', 'total_used_bytes', 'total_objects']
 DF_POOL = ['max_avail', 'bytes_used', 'raw_bytes_used', 'objects', 'dirty',
            'quota_bytes', 'quota_objects', 'rd', 'rd_bytes', 'wr', 'wr_bytes']
 
+OSD_FLAGS = ('noup', 'nodown', 'noout', 'noin', 'nobackfill', 'norebalance',
+             'norecover', 'noscrub', 'nodeep-scrub')
+
 OSD_METADATA = ('cluster_addr', 'device_class', 'id', 'public_addr')
 
 OSD_STATUS = ['weight', 'up', 'in']
@@ -202,6 +205,13 @@ class Module(MgrModule):
             'PG Total Count'
         )
 
+        for flag in OSD_FLAGS:
+            path = 'osd_flag_{}'.format(flag)
+            metrics[path] = Metric(
+                'untyped',
+                path,
+                'OSD Flag {}'.format(flag)
+            )
         for state in OSD_STATUS:
             path = 'osd_{}'.format(state)
             self.log.debug("init: creating {}".format(path))
@@ -315,6 +325,11 @@ class Module(MgrModule):
 
     def get_metadata_and_osd_status(self):
         osd_map = self.get('osd_map')
+        osd_flags = osd_map['flags'].split(',')
+        for flag in OSD_FLAGS:
+            self.metrics['osd_flag_{}'.format(flag)].set(
+                int(flag in osd_flags)
+            )
         osd_devices = self.get('osd_map_crush')['devices']
         for osd in osd_map['osds']:
             id_ = osd['osd']