]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/telemetry: add command to list all channels
authorYaarit Hatuka <yaarit@redhat.com>
Tue, 23 Nov 2021 17:11:38 +0000 (17:11 +0000)
committerYaarit Hatuka <yaarit@redhat.com>
Thu, 13 Jan 2022 21:53:47 +0000 (21:53 +0000)
List all channels, their current state, default, and description, with:

$ ceph telemetry channel ls

NAME      ENABLED    DEFAULT    DESC
basic     ON         ON         Share basic cluster information (size, version)
ident     OFF        OFF        Share a user-provided description and/or contact email for the cluster
crash     ON         ON         Share metadata about Ceph daemon crashes (version, stack straces, etc)
device    ON         ON         Share device health metrics (e.g., SMART data, minus potentially identifying info like serial numbers)
perf      ON         OFF        Share perf counter metrics summed across the whole cluster

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

index e0b09dc4b3793a59987980d689262638e1177a7d..82cb4efcbc6ef397bc1416d1ff2c2a0397484da8 100644 (file)
@@ -15,6 +15,7 @@ import requests
 import uuid
 import time
 from datetime import datetime, timedelta
+from prettytable import PrettyTable
 from threading import Event, Lock
 from collections import defaultdict
 from typing import cast, Any, DefaultDict, Dict, List, Optional, Tuple, TypeVar, TYPE_CHECKING, Union
@@ -1439,6 +1440,39 @@ To enable, add '--license {LICENSE}' to the 'ceph telemetry on' command.'''
         '''
         return self.toggle_channel('disable', channels)
 
+    @CLIReadCommand('telemetry channel ls')
+    def channel_ls(self) -> Tuple[int, str, str]:
+        '''
+        List all channels
+        '''
+        table = PrettyTable(
+            [
+                'NAME', 'ENABLED', 'DEFAULT', 'DESC',
+            ],
+            border=False)
+        table.align['NAME'] = 'l'
+        table.align['ENABLED'] = 'l'
+        table.align['DEFAULT'] = 'l'
+        table.align['DESC'] = 'l'
+        table.left_padding_width = 0
+        table.right_padding_width = 4
+
+        for c in ALL_CHANNELS:
+            enabled = "ON" if getattr(self, f"channel_{c}") else "OFF"
+            for o in self.MODULE_OPTIONS:
+                if o['name'] == f"channel_{c}":
+                    default = "ON" if o.get('default', None) else "OFF"
+                    desc = o.get('desc', None)
+
+            table.add_row((
+                c,
+                enabled,
+                default,
+                desc,
+            ))
+
+        return 0, table.get_string(), ''
+
     @CLICommand('telemetry send')
     def do_send(self,
                 endpoint: Optional[List[EndPoint]] = None,