]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: accept channel list to 'telemetry show'
authorSage Weil <sage@redhat.com>
Tue, 9 Jul 2019 19:25:23 +0000 (14:25 -0500)
committerSage Weil <sage@redhat.com>
Wed, 6 Nov 2019 12:41:50 +0000 (06:41 -0600)
Also include a 'channels_available' item so that a user can tell which
channels are available.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit e9fdb219c1b946dc2b346b11c5e5d4b04786345d)

src/pybind/mgr/telemetry/module.py

index 3a73d1072a898497956562e776ccaa3c7e26399b..fa4744018a5e2bec4d2162050ee1a3128df50493 100644 (file)
@@ -16,6 +16,7 @@ from collections import defaultdict
 
 from mgr_module import MgrModule
 
+ALL_CHANNELS = ['basic', 'crash', 'device']
 
 class Module(MgrModule):
     config = dict()
@@ -105,7 +106,8 @@ class Module(MgrModule):
             "perm": "rw"
         },
         {
-            "cmd": "telemetry show",
+            "cmd": "telemetry show "
+                   "name=channels,type=CephString,n=N,req=False",
             "desc": "Show last report or report to be sent",
             "perm": "r"
         },
@@ -219,13 +221,16 @@ class Module(MgrModule):
         except:
             return None
 
-    def compile_report(self):
+    def compile_report(self, channels=[]):
+        if not channels:
+            channels = self.get_active_channels()
         report = {
             'leaderboard': False,
             'report_version': 1,
             'report_timestamp': datetime.utcnow().isoformat(),
             'report_id': self.report_id,
-            'channels': self.get_active_channels(),
+            'channels': channels,
+            'channels_available': ALL_CHANNELS,
         }
 
         if self.leaderboard:
@@ -234,7 +239,7 @@ class Module(MgrModule):
         for option in ['description', 'contact', 'organization']:
             report[option] = getattr(self, option)
 
-        if self.channel_basic:
+        if 'basic' in channels:
             mon_map = self.get('mon_map')
             osd_map = self.get('osd_map')
             service_map = self.get('service_map')
@@ -290,10 +295,10 @@ class Module(MgrModule):
             for key, value in service_map['services'].items():
                 report['services'][key] += 1
 
-        if self.channel_crash:
+        if 'crash' in channels:
             report['crashes'] = self.gather_crashinfo()
 
-        if self.channel_devices:
+        if 'device' in channels:
             report['devices'] = self.gather_device_report()
 
         return report
@@ -337,7 +342,9 @@ class Module(MgrModule):
             )
 
         elif command['prefix'] == 'telemetry show':
-            report = self.compile_report()
+            report = self.compile_report(
+                channels=command.get('channels', None)
+            )
             return 0, json.dumps(report, indent=4), ''
         else:
             return (-errno.EINVAL, '',