From: John Spray Date: Tue, 12 Sep 2017 14:27:12 +0000 (-0400) Subject: mgr/prometheus: add a self-test command X-Git-Tag: v12.2.2~61^2~58 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3dff5c0f39289e02e882bf86bf3e23e94ee33aa8;p=ceph.git mgr/prometheus: add a self-test command Signed-off-by: John Spray (cherry picked from commit 76e1ba52b1b95d417cdd04b8fe985acee648f0e9) --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index a7efbfc7fde1..adb0850e96e7 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1,5 +1,6 @@ import cherrypy import json +import errno import math import os from collections import OrderedDict @@ -234,6 +235,13 @@ class Metric(object): class Module(MgrModule): + COMMANDS = [ + { + "cmd": "prometheus self-test", + "desc": "Run a self test on the prometheus module", + "perm": "rw" + }, + ] def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) @@ -388,6 +396,14 @@ class Module(MgrModule): return self.metrics + def handle_command(self, cmd): + if cmd['prefix'] == 'prometheus self-test': + self.collect() + return 0, '', 'Self-test OK' + else: + return (-errno.EINVAL, '', + "Command not found '{0}'".format(cmd['prefix'])) + def serve(self): class Root(object):