]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr_module: move PRIO_* and PERFCOUNTER_* to MgrModule class 18251/head
authorJan Fajerski <jfajerski@suse.com>
Wed, 11 Oct 2017 18:07:19 +0000 (20:07 +0200)
committerJan Fajerski <jfajerski@suse.com>
Wed, 11 Oct 2017 18:07:19 +0000 (20:07 +0200)
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/pybind/mgr/influx/module.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/prometheus/module.py

index ca18f6e2117efce0070e02bea0099522f4cc1b2f..b2aef2458720f958b23693b45ce98bf580dc60f9 100644 (file)
@@ -5,7 +5,6 @@ import json
 import errno
 
 from mgr_module import MgrModule
-from mgr_module import PERFCOUNTER_HISTOGRAM
 
 try:
     from influxdb import InfluxDBClient
@@ -76,7 +75,7 @@ class Module(MgrModule):
             metadata = self.get_metadata(svc_type, svc_id)
 
             for path, counter_info in counters.items():
-                if counter_info['type'] & PERFCOUNTER_HISTOGRAM:
+                if counter_info['type'] & self.PERFCOUNTER_HISTOGRAM:
                     continue
 
                 value = counter_info['value']
index f8ad75e961cdeae4957dd3c287a4cc843db4c4f7..22ee148a1c941ca57740de86940f99c3085bcdb2 100644 (file)
@@ -9,24 +9,6 @@ import threading
 from collections import defaultdict
 
 
-# Priority definitions for perf counters
-PRIO_CRITICAL = 10
-PRIO_INTERESTING = 8
-PRIO_USEFUL = 5
-PRIO_UNINTERESTING = 2
-PRIO_DEBUGONLY = 0
-
-# counter value types
-PERFCOUNTER_TIME = 1
-PERFCOUNTER_U64 = 2
-
-# counter types
-PERFCOUNTER_LONGRUNAVG = 4
-PERFCOUNTER_COUNTER = 8
-PERFCOUNTER_HISTOGRAM = 0x10
-PERFCOUNTER_TYPE_MASK = ~2
-
-
 class CommandResult(object):
     """
     Use with MgrModule.send_command
@@ -136,6 +118,23 @@ class CRUSHMap(object):
 class MgrModule(object):
     COMMANDS = []
 
+    # Priority definitions for perf counters
+    PRIO_CRITICAL = 10
+    PRIO_INTERESTING = 8
+    PRIO_USEFUL = 5
+    PRIO_UNINTERESTING = 2
+    PRIO_DEBUGONLY = 0
+
+    # counter value types
+    PERFCOUNTER_TIME = 1
+    PERFCOUNTER_U64 = 2
+
+    # counter types
+    PERFCOUNTER_LONGRUNAVG = 4
+    PERFCOUNTER_COUNTER = 8
+    PERFCOUNTER_HISTOGRAM = 0x10
+    PERFCOUNTER_TYPE_MASK = ~2
+
     def __init__(self, handle):
         self._handle = handle
         self._logger = logging.getLogger(handle)
index 2b22b67e8c11916b7d3fbc36e1b11ea78f94a802..b480d1b6532b3ebbad7a5f457e9f7b4ddb9b541a 100644 (file)
@@ -33,33 +33,6 @@ def global_instance():
     return _global_instance['plugin']
 
 
-# counter value types
-PERFCOUNTER_TIME = 1
-PERFCOUNTER_U64 = 2
-
-# counter types
-PERFCOUNTER_LONGRUNAVG = 4
-PERFCOUNTER_COUNTER = 8
-PERFCOUNTER_HISTOGRAM = 0x10
-PERFCOUNTER_TYPE_MASK = ~2
-
-
-def stattype_to_str(stattype):
-
-    typeonly = stattype & PERFCOUNTER_TYPE_MASK
-    if typeonly == 0:
-        return 'gauge'
-    if typeonly == PERFCOUNTER_LONGRUNAVG:
-        # this lie matches the DaemonState decoding: only val, no counts
-        return 'counter'
-    if typeonly == PERFCOUNTER_COUNTER:
-        return 'counter'
-    if typeonly == PERFCOUNTER_HISTOGRAM:
-        return 'histogram'
-
-    return ''
-
-
 def health_status_to_number(status):
 
     if status == 'HEALTH_OK':
@@ -166,6 +139,21 @@ class Module(MgrModule):
         self.schema = OrderedDict()
         _global_instance['plugin'] = self
 
+    def _stattype_to_str(self, stattype):
+
+        typeonly = stattype & self.PERFCOUNTER_TYPE_MASK
+        if typeonly == 0:
+            return 'gauge'
+        if typeonly == self.PERFCOUNTER_LONGRUNAVG:
+            # this lie matches the DaemonState decoding: only val, no counts
+            return 'counter'
+        if typeonly == self.PERFCOUNTER_COUNTER:
+            return 'counter'
+        if typeonly == self.PERFCOUNTER_HISTOGRAM:
+            return 'histogram'
+
+        return ''
+
     def _setup_static_metrics(self):
         metrics = {}
         metrics['health_status'] = Metric(
@@ -289,7 +277,7 @@ class Module(MgrModule):
 
         for daemon, counters in self.get_all_perf_counters().iteritems():
             for path, counter_info in counters.items():
-                stattype = stattype_to_str(counter_info['type'])
+                stattype = self._stattype_to_str(counter_info['type'])
                 # XXX simplify first effort: no histograms
                 # averages are already collapsed to one value for us
                 if not stattype or stattype == 'histogram':