]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: add command to list all collections
authorYaarit Hatuka <yaarit@redhat.com>
Tue, 7 Dec 2021 18:30:56 +0000 (18:30 +0000)
committerYaarit Hatuka <yaarit@redhat.com>
Thu, 13 Jan 2022 21:53:47 +0000 (21:53 +0000)
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 <yaarit@redhat.com>
src/pybind/mgr/telemetry/module.py

index 3f773ad78324062d3566c324f530f32d37ce0a4c..2a00dea157749d7d708a6a8b9e6a252911c3af7b 100644 (file)
@@ -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,