From: Yaarit Hatuka Date: Tue, 23 Nov 2021 17:11:38 +0000 (+0000) Subject: mgr/telemetry: add command to list all channels X-Git-Tag: v17.1.0~50^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1c1fcad510c434ae51e7578ce3926a44d64dbe5e;p=ceph.git mgr/telemetry: add command to list all channels 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 --- diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index e0b09dc4b3793..82cb4efcbc6ef 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -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,