From 8d91443c8b932f8d24017e72cbbae58616928ab9 Mon Sep 17 00:00:00 2001 From: Tatjana Dehler Date: Tue, 7 Apr 2020 17:18:27 +0200 Subject: [PATCH] mgr/telemetry: refactor/enhance CLI commands 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 --- doc/mgr/telemetry.rst | 9 +++++-- src/pybind/mgr/telemetry/module.py | 39 +++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/doc/mgr/telemetry.rst b/doc/mgr/telemetry.rst index 3e9292be53a..64c2d0f0e5b 100644 --- a/doc/mgr/telemetry.rst +++ b/doc/mgr/telemetry.rst @@ -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 `_ +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 diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 4fbfe8f7c03..fef56e4bd45 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -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: -- 2.39.5