]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: Centralize PG_STATES to MgrModule 22594/head
authorWido den Hollander <wido@42on.com>
Mon, 18 Jun 2018 10:26:38 +0000 (12:26 +0200)
committerWido den Hollander <wido@42on.com>
Mon, 9 Jul 2018 11:30:33 +0000 (13:30 +0200)
The Prometheus, Telegraf and Influx module can use this list
of states to send information about Placement Groups to their
endpoint.

Signed-off-by: Wido den Hollander <wido@42on.com>
src/pybind/mgr/mgr_module.py
src/pybind/mgr/prometheus/module.py
src/pybind/mgr/telegraf/module.py

index 396fbafe35b3e10d9e626d1611f2a3dcb10f05d2..629aee22ac2cb6fbda4dffc83bfdf5c81a7a4bf5 100644 (file)
@@ -8,6 +8,37 @@ import threading
 from collections import defaultdict
 import rados
 
+PG_STATES = [
+        "active",
+        "clean",
+        "down",
+        "recovery_unfound",
+        "backfill_unfound",
+        "scrubbing",
+        "degraded",
+        "inconsistent",
+        "peering",
+        "repair",
+        "recovering",
+        "forced_recovery",
+        "backfill_wait",
+        "incomplete",
+        "stale",
+        "remapped",
+        "deep",
+        "backfilling",
+        "forced_backfill",
+        "backfill_toofull",
+        "recovery_wait",
+        "recovery_toofull",
+        "undersized",
+        "activating",
+        "peered",
+        "snaptrim",
+        "snaptrim_wait",
+        "snaptrim_error",
+        "creating",
+        "unknown"]
 
 class CPlusPlusHandler(logging.Handler):
     def __init__(self, module_inst):
index 85724a9dc361ada97dbcaac51334d27990e51e64..0d5d4febed88f28ae7cd82b4cb4acace288e0fd3 100644 (file)
@@ -6,7 +6,7 @@ import os
 import socket
 import threading
 from collections import OrderedDict
-from mgr_module import MgrModule, MgrStandbyModule, CommandResult
+from mgr_module import MgrModule, MgrStandbyModule, CommandResult, PG_STATES
 
 # Defaults for the Prometheus HTTP server.  Can also set in config-key
 # see https://github.com/prometheus/prometheus/wiki/Default-port-allocations
@@ -44,38 +44,6 @@ def health_status_to_number(status):
     elif status == 'HEALTH_ERR':
         return 2
 
-PG_STATES = [
-        "active",
-        "clean",
-        "down",
-        "recovery_unfound",
-        "backfill_unfound",
-        "scrubbing",
-        "degraded",
-        "inconsistent",
-        "peering",
-        "repair",
-        "recovering",
-        "forced_recovery",
-        "backfill_wait",
-        "incomplete",
-        "stale",
-        "remapped",
-        "deep",
-        "backfilling",
-        "forced_backfill",
-        "backfill_toofull",
-        "recovery_wait",
-        "recovery_toofull",
-        "undersized",
-        "activating",
-        "peered",
-        "snaptrim",
-        "snaptrim_wait",
-        "snaptrim_error",
-        "creating",
-        "unknown"]
-
 DF_CLUSTER = ['total_bytes', 'total_used_bytes', 'total_objects']
 
 DF_POOL = ['max_avail', 'bytes_used', 'raw_bytes_used', 'objects', 'dirty',
index e58e992e6ceed0d8658ca2769036d906b4bcafd4..cfe87781c89973a03f87e6bbd32e421314365f37 100644 (file)
@@ -8,7 +8,7 @@ from threading import Event
 
 from telegraf.basesocket import BaseSocket
 from telegraf.protocol import Line
-from mgr_module import MgrModule
+from mgr_module import MgrModule, PG_STATES
 
 try:
     from urllib.parse import urlparse
@@ -130,18 +130,13 @@ class Module(MgrModule):
                     'num_pgs', 'num_objects', 'num_pools']:
             stats[key] = pg_status[key]
 
-        pg_states = ['active', 'peering', 'clean', 'scrubbing', 'undersized',
-                     'backfilling', 'recovering', 'degraded', 'inconsistent',
-                     'remapped', 'backfill_toofull', 'wait_backfill',
-                     'recovery_wait']
-
-        for state in pg_states:
+        for state in PG_STATES:
             stats['num_pgs_{0}'.format(state)] = 0
 
         stats['num_pgs'] = pg_status['num_pgs']
         for state in pg_status['pgs_by_state']:
             states = state['state_name'].split('+')
-            for s in pg_states:
+            for s in PG_STATES:
                 key = 'num_pgs_{0}'.format(s)
                 if s in states:
                     stats[key] += state['count']