]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: refactor/enhance CLI commands
authorTatjana Dehler <tdehler@suse.com>
Tue, 7 Apr 2020 15:18:27 +0000 (17:18 +0200)
committerTatjana Dehler <tdehler@suse.com>
Mon, 4 May 2020 14:10:42 +0000 (16:10 +0200)
1. Move the implementations of the `on` and `off`
command into dedicated methods so that they can
be accessed by other mgr modules via `mgr.remote`.

2. Add a `show-all` command to return the report
and device report at once. Also add a method
`get_report` to make the reports accessible for
other mgr modules as mentioned above.

3. Add two  minor changes and a note where the
gathered data can be found to the Telemetry docu
file.

Signed-off-by: Tatjana Dehler <tdehler@suse.com>
(cherry picked from commit 8d91443c8b932f8d24017e72cbbae58616928ab9)

doc/mgr/telemetry.rst
src/pybind/mgr/telemetry/module.py

index 3e9292be53a2860fd42f4991e09a2c041ce302c2..64c2d0f0e5b4a794195042107934449a31c8ca9a 100644 (file)
@@ -7,10 +7,15 @@ The telemetry module sends anonymous data about the cluster back to the Ceph
 developers to help understand how Ceph is used and what problems users may
 be experiencing.
 
+This data is visualized on `public dashboards <https://telemetry-public.ceph.com/>`_
+that allow the community to quickly see summary statistics on how many clusters
+are reporting, their total capacity and OSD count, and version distribution
+trends.
+
 Channels
 --------
 
-The telemetry report is broken down into several "channels," each with
+The telemetry report is broken down into several "channels", each with
 a different type of information.  Assuming telemetry has been enabled,
 individual channels can be turned on and off.  (If telemetry is off,
 the per-channel setting has no effect.)
@@ -18,7 +23,7 @@ the per-channel setting has no effect.)
 * **basic** (default: on): Basic information about the cluster
 
     - capacity of the cluster
-    - number of monitors, managers, OSDs, MDSs, radosgws, or other daemons
+    - number of monitors, managers, OSDs, MDSs, object gateways, or other daemons
     - software version currently being used
     - number and types of RADOS pools and CephFS file systems
     - names of configuration options that have been changed from their
index 4fbfe8f7c03e4e4e814d8cdac6e0598392211747..fef56e4bd45d57d6074f3f9b1ac55ee440096c0c 100644 (file)
@@ -175,6 +175,11 @@ class Module(MgrModule):
             "desc": "Show last device report or device report to be sent",
             "perm": "r"
         },
+        {
+            "cmd": "telemetry show-all",
+            "desc": "Show report of all channels",
+            "perm": "r"
+        },
         {
             "cmd": "telemetry on name=license,type=CephString,req=false",
             "desc": "Enable telemetry reports from this cluster",
@@ -740,12 +745,10 @@ class Module(MgrModule):
         elif command['prefix'] == 'telemetry on':
             if command.get('license') != LICENSE:
                 return -errno.EPERM, '', "Telemetry data is licensed under the " + LICENSE_NAME + " (" + LICENSE_URL + ").\nTo enable, add '--license " + LICENSE + "' to the 'ceph telemetry on' command."
-            self.set_module_option('enabled', True)
-            self.set_module_option('last_opt_revision', REVISION)
+            self.on()
             return 0, '', ''
         elif command['prefix'] == 'telemetry off':
-            self.set_module_option('enabled', False)
-            self.set_module_option('last_opt_revision', 1)
+            self.off()
             return 0, '', ''
         elif command['prefix'] == 'telemetry send':
             if self.last_opt_revision < LAST_REVISION_RE_OPT_IN and command.get('license') != LICENSE:
@@ -755,19 +758,37 @@ class Module(MgrModule):
             return self.send(self.last_report, command.get('endpoint'))
 
         elif command['prefix'] == 'telemetry show':
-            report = self.compile_report(
-                channels=command.get('channels', None)
-            )
+            report = self.get_report(channels=command.get('channels', None))
             report = json.dumps(report, indent=4, sort_keys=True)
             if self.channel_device:
-               report += '\n \nDevice report is generated separately. To see it run \'ceph telemetry show-device\'.'
+                report += '\n \nDevice report is generated separately. To see it run \'ceph telemetry show-device\'.'
             return 0, report, ''
         elif command['prefix'] == 'telemetry show-device':
-            return 0, json.dumps(self.gather_device_report(), indent=4, sort_keys=True), ''
+            return 0, json.dumps(self.get_report('device'), indent=4, sort_keys=True), ''
+        elif command['prefix'] == 'telemetry show-all':
+            return 0, json.dumps(self.get_report('all'), indent=4, sort_keys=True), ''
         else:
             return (-errno.EINVAL, '',
                     "Command not found '{0}'".format(command['prefix']))
 
+    def on(self):
+        self.set_module_option('enabled', True)
+        self.set_module_option('last_opt_revision', REVISION)
+
+    def off(self):
+        self.set_module_option('enabled', False)
+        self.set_module_option('last_opt_revision', 1)
+
+    def get_report(self, report_type='default', channels=None):
+        if report_type == 'default':
+            return self.compile_report(channels=channels)
+        elif report_type == 'device':
+            return self.gather_device_report()
+        elif report_type == 'all':
+            return {'report': self.compile_report(channels=channels),
+                    'device_report': self.gather_device_report()}
+        return {}
+
     def self_test(self):
         report = self.compile_report()
         if len(report) == 0: