mirror of
https://github.com/ceph/ceph
synced 2024-12-19 09:57:05 +00:00
Merge pull request #18251 from jan--f/mgr-py-module-constants
pybind/mgr_module: move PRIO_* and PERFCOUNTER_* to MgrModule class Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
commit
8c45855325
@ -5,7 +5,6 @@ import json
|
||||
import errno
|
||||
|
||||
from mgr_module import MgrModule
|
||||
from mgr_module import PERFCOUNTER_HISTOGRAM
|
||||
|
||||
try:
|
||||
from influxdb import InfluxDBClient
|
||||
@ -77,7 +76,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']
|
||||
|
@ -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)
|
||||
|
@ -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':
|
||||
@ -168,6 +141,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(
|
||||
@ -323,7 +311,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':
|
||||
|
Loading…
Reference in New Issue
Block a user