]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/services/ceph_service.py
import ceph 16.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / ceph_service.py
index 4cf82f06696d87341b6694c06dafe70fbbbf6aa2..a4d0fbca9c74b0b80ff7b0f165b7aae8a0f083ac 100644 (file)
@@ -26,6 +26,7 @@ class SendCommandError(rados.Error):
         super(SendCommandError, self).__init__(err, errno)
 
 
+# pylint: disable=too-many-public-methods
 class CephService(object):
 
     OSD_FLAG_NO_SCRUB = 'noscrub'
@@ -91,6 +92,32 @@ class CephService(object):
             svc_data['status'] = mgr.get_daemon_status(svc_data['type'], svc_data['service_map_id'])
         return svc_data
 
+    @classmethod
+    def get_service_perf_counters(cls, service_type: str, service_id: str) -> Dict[str, Any]:
+        schema_dict = mgr.get_perf_schema(service_type, service_id)
+        schema = schema_dict["{}.{}".format(service_type, service_id)]
+        counters = []
+        for key, value in sorted(schema.items()):
+            counter = {'name': str(key), 'description': value['description']}
+            # pylint: disable=W0212
+            if mgr._stattype_to_str(value['type']) == 'counter':
+                counter['value'] = cls.get_rate(
+                    service_type, service_id, key)
+                counter['unit'] = mgr._unit_to_str(value['units'])
+            else:
+                counter['value'] = mgr.get_latest(
+                    service_type, service_id, key)
+                counter['unit'] = ''
+            counters.append(counter)
+
+        return {
+            'service': {
+                'type': service_type,
+                'id': str(service_id)
+            },
+            'counters': counters
+        }
+
     @classmethod
     def get_pool_list(cls, application=None):
         osd_map = mgr.get('osd_map')