]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: add a self-test command
authorJohn Spray <john.spray@redhat.com>
Tue, 12 Sep 2017 14:27:12 +0000 (10:27 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 23:03:25 +0000 (23:03 +0000)
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 76e1ba52b1b95d417cdd04b8fe985acee648f0e9)

src/pybind/mgr/prometheus/module.py

index a7efbfc7fde16fe44ba8e9c4be8e6353c2e80545..adb0850e96e7458862eb6358301613a3b770d9b0 100644 (file)
@@ -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):