]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: improve output of `ceph telemetry collection ls`
authorYaarit Hatuka <yaarit@redhat.com>
Wed, 12 Jan 2022 04:36:27 +0000 (04:36 +0000)
committerYaarit Hatuka <yaarit@redhat.com>
Thu, 13 Jan 2022 21:54:07 +0000 (21:54 +0000)
STATUS column now indicates whether a collection is being reported, and
the reasons why it's not (either the user is not opted-in to this
collection, or its channel is off).

Also, removed the ENROLLED and DEFAULT columns due to potential
confusion they may cause.

In case a user is not opted-in to certain collections, a message will
appear above the table with the missing collections:

    New collections are available:
    ['basic_base', 'basic_mds_metadata', 'crash_base', 'device_base',
    'ident_base', 'perf_perf']
    Run `ceph telemetry on` to opt-in to these collections.

Signed-off-by: Yaarit Hatuka <yaarit@redhat.com>
doc/mgr/telemetry.rst
src/pybind/mgr/telemetry/module.py

index 12beff8f861d54d3f9bf1dd09070cf7e7db699aa..6927a19332f04b3582e3660c2cdc3ad3728e1f5b 100644 (file)
@@ -178,29 +178,23 @@ List all collections with::
 
   ceph telemetry collection ls
 
-  NAME                  ENROLLED    STATUS    DEFAULT    DESC
-  basic_base            FALSE       OFF       ON         Basic information about the cluster (capacity, number and type of daemons, version, etc.)
-  basic_mds_metadata    FALSE       OFF       ON         MDS metadata
-  crash_base            FALSE       OFF       ON         Information about daemon crashes (daemon type and version, backtrace, etc.)
-  device_base           FALSE       OFF       ON         Information about device health metrics
-  ident_base            FALSE       OFF       OFF        User-provided identifying information about the cluster
-  perf_perf             FALSE       OFF       OFF        Information about performance of the cluster
+  NAME                  STATUS                                               DESC
+  basic_base            REPORTING                                            Basic information about the cluster (capacity, number and type of daemons, version, etc.)
+  basic_mds_metadata    NOT REPORTING: NOT OPTED-IN                          MDS metadata
+  crash_base            REPORTING                                            Information about daemon crashes (daemon type and version, backtrace, etc.)
+  device_base           REPORTING                                            Information about device health metrics
+  ident_base            NOT REPORTING: CHANNEL ident IS OFF                  User-provided identifying information about the cluster
+  perf_perf             NOT REPORTING: NOT OPTED-IN, CHANNEL perf IS OFF     Information about performance counters of the cluster
+
 
 Where:
 
 **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.
-The STATUS column indicates whether the collection is being reported.
-
 **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.
+belongs to, along with the enrollment status of the collection (whether the user
+is opted-in to this collection).
 
 **DESC**: General description of the collection.
 
index 100b84f7d7c99eb24f16aa76054418bf32735885..4d75bb914da1a153e09e89b045138b320af87355 100644 (file)
@@ -1495,41 +1495,57 @@ To enable, add '--license {LICENSE}' to the 'ceph telemetry on' command.'''
         '''
         List all collections
         '''
+        col_delta = self.collection_delta()
+        msg = ''
+        if col_delta is not None and len(col_delta) > 0:
+            msg = f"New collections are available:\n" \
+                  f"{sorted([c.name for c in col_delta])}\n" \
+                  f"Run `ceph telemetry on` to opt-in to these collections.\n"
+
         table = PrettyTable(
             [
-                'NAME', 'ENROLLED', 'STATUS', 'DEFAULT', 'DESC',
+                'NAME', 'STATUS', '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"
+            opted_in = self.is_enabled_collection(name)
+            channel_enabled = getattr(self, f"channel_{c['channel']}")
+
+            status = ''
+            if channel_enabled and opted_in:
+                status = "REPORTING"
+            else:
+                why = ''
+                delimiter = ''
+
+                if not opted_in:
+                    why += "NOT OPTED-IN"
+                    delimiter = ', '
+                if not channel_enabled:
+                    why += f"{delimiter}CHANNEL {c['channel']} IS OFF"
+
+                status = f"NOT REPORTING: {why}"
 
             desc = c['description']
 
             table.add_row((
                 name,
-                enrolled,
                 status,
-                default,
                 desc,
             ))
 
-        return 0, table.get_string(sortby="NAME"), ''
+        if len(msg):
+            # add a new line between message and table output
+            msg = f"{msg} \n"
+
+        return 0, f'{msg}{table.get_string(sortby="NAME")}', ''
 
     @CLICommand('telemetry send')
     def do_send(self,