]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/mgr_module.py
update sources to 12.2.7
[ceph.git] / ceph / src / pybind / mgr / mgr_module.py
index 38283d2446d34bf0ef957c1c5f1e18eab3cfb76e..230d6f20b928d3d7ad9a86e45994af5f214480a7 100644 (file)
@@ -221,7 +221,7 @@ class MgrModule(ceph_module.BaseMgrModule):
     PERFCOUNTER_LONGRUNAVG = 4
     PERFCOUNTER_COUNTER = 8
     PERFCOUNTER_HISTOGRAM = 0x10
-    PERFCOUNTER_TYPE_MASK = ~2
+    PERFCOUNTER_TYPE_MASK = ~3
 
     def __init__(self, module_name, py_modules_ptr, this_ptr):
         self.module_name = module_name
@@ -313,6 +313,13 @@ class MgrModule(ceph_module.BaseMgrModule):
         
         return ''
 
+    def _perfvalue_to_value(self, stattype, value):
+        if stattype & self.PERFCOUNTER_TIME:
+            # Convert from ns to seconds
+            return value / 1000000000.0
+        else:
+            return value
+
     def get_server(self, hostname):
         """
         Called by the plugin to load information about a particular
@@ -547,6 +554,13 @@ class MgrModule(ceph_module.BaseMgrModule):
             else:
                 return 0
 
+        def get_latest_avg(daemon_type, daemon_name, counter):
+            data = self.get_counter(daemon_type, daemon_name, counter)[counter]
+            if data:
+                return (data[-1][1], data[-1][2])
+            else:
+                return (0, 0)
+
         for server in self.list_servers():
             for service in server['services']:
                 if service['type'] not in ("rgw", "mds", "osd", "mon"):
@@ -572,8 +586,24 @@ class MgrModule(ceph_module.BaseMgrModule):
                     if counter_schema['priority'] < prio_limit:
                         continue
 
-                    counter_info = counter_schema
-                    counter_info['value'] = get_latest(service['type'], service['id'], counter_path)
+                    counter_info = dict(counter_schema)
+
+                    # Also populate count for the long running avgs
+                    if counter_schema['type'] & self.PERFCOUNTER_LONGRUNAVG:
+                        v, c = get_latest_avg(
+                            service['type'],
+                            service['id'],
+                            counter_path
+                        )
+                        counter_info['value'], counter_info['count'] = v, c
+                        result[svc_full_name][counter_path] = counter_info
+                    else:
+                        counter_info['value'] = get_latest(
+                            service['type'],
+                            service['id'],
+                            counter_path
+                        )
+
                     result[svc_full_name][counter_path] = counter_info
 
         self.log.debug("returning {0} counter".format(len(result)))
@@ -597,4 +627,4 @@ class MgrModule(ceph_module.BaseMgrModule):
         and/or the monitor cluster is down.
         """
 
-        return self._ceph_have_mon_connection()
\ No newline at end of file
+        return self._ceph_have_mon_connection()