From 7241fe96ebea1d61eb49158ca55b9caf5ba16c9f Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Tue, 7 Dec 2021 18:30:56 +0000 Subject: [PATCH] mgr/telemetry: add command to list all collections List all collections, their current enrollment state, status, default, and description, with: $ ceph telemetry collection ls NAME ENROLLED STATUS DEFAULT DESC basic_base TRUE ON ON Basic information about the cluster (capacity, number and type of daemons, version, etc.) basic_mds_metadata TRUE ON ON MDS metadata crash_base TRUE ON ON Information about daemon crashes (daemon type and version, backtrace, etc.) device_base TRUE ON ON Information about device health metrics ident_base TRUE OFF OFF User-provided identifying information about the cluster perf_perf TRUE OFF OFF Information about performance counters of the cluster Please note: NAME: ===== Collection name; prefix indicates the channel the collection belongs to. ENROLLED: ========= Signifies the collections that were available in the module when the user last opted-in to telemetry. Please note: Even if a collection is 'enrolled', its metrics will be reported only if its channel is enabled. STATUS: ======= Indicates whether the collection metrics are reported; this is determined by the status (enabled / disabled) of the channel the collection belongs to, along with the enrollment status of the collection. DEFAULT: ======== The default status (enabled / disabled) of the channel the collection belongs to. DESC: ===== Collection description. Signed-off-by: Yaarit Hatuka --- src/pybind/mgr/telemetry/module.py | 43 +++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 3f773ad783240..2a00dea157749 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -1493,7 +1493,48 @@ To enable, add '--license {LICENSE}' to the 'ceph telemetry on' command.''' desc, )) - return 0, table.get_string(), '' + return 0, table.get_string(sortby="NAME"), '' + + @CLIReadCommand('telemetry collection ls') + def collection_ls(self) -> Tuple[int, str, str]: + ''' + List all collections + ''' + table = PrettyTable( + [ + 'NAME', 'ENROLLED', 'STATUS', 'DEFAULT', 'DESC', + ], + border=False) + table.align['NAME'] = 'l' + table.align['ENROLLED'] = 'l' + table.align['STATUS'] = 'l' + table.align['DEFAULT'] = 'l' + table.align['DESC'] = 'l' + table.left_padding_width = 0 + table.right_padding_width = 4 + + for c in MODULE_COLLECTION: + name = c['name'] + enrolled = "TRUE" if self.is_enabled_collection(name) else "FALSE" + status = "ON" if getattr(self, f"channel_{c['channel']}") and self.is_enabled_collection(name) \ + else "OFF" + # default value of *channel*, since we check for active channels + # when generating reports + for o in self.MODULE_OPTIONS: + if o['name'] == f"channel_{c['channel']}": + default = "ON" if o.get('default', None) else "OFF" + + desc = c['description'] + + table.add_row(( + name, + enrolled, + status, + default, + desc, + )) + + return 0, table.get_string(sortby="NAME"), '' @CLICommand('telemetry send') def do_send(self, -- 2.39.5