From cae87cc42935cd5cc6c6a2096af215b8dc64171d Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Fri, 31 Jan 2020 16:36:23 -0500 Subject: [PATCH 1/2] mgr/telemetry: added 'telemetry show-device' command Added 'telemetry show-device' command to print a preview of telemetry device report. Added a message at the bottom of 'telemetry show' about 'telemetry show-device' new command. Signed-off-by: Yaarit Hatuka --- src/pybind/mgr/telemetry/module.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index 97b35353893..ce8dd71e51a 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -169,6 +169,11 @@ class Module(MgrModule): "desc": "Show last report or report to be sent", "perm": "r" }, + { + "cmd": "telemetry show-device", + "desc": "Show last device report or device report to be sent", + "perm": "r" + }, { "cmd": "telemetry on name=license,type=CephString,req=false", "desc": "Enable telemetry reports from this cluster", @@ -748,7 +753,12 @@ class Module(MgrModule): report = self.compile_report( channels=command.get('channels', None) ) - return 0, json.dumps(report, indent=4, sort_keys=True), '' + report = json.dumps(report, indent=4, sort_keys=True) + if self.channel_device: + report += '\n \nDevice report is generated separately. To see it run \'ceph telemetry show-device\'.' + return 0, report, '' + elif command['prefix'] == 'telemetry show-device': + return 0, json.dumps(self.gather_device_report(), indent=4, sort_keys=True), '' else: return (-errno.EINVAL, '', "Command not found '{0}'".format(command['prefix'])) From be1257f324684cd3034f89ac1421b366cac66822 Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Fri, 31 Jan 2020 16:44:30 -0500 Subject: [PATCH 2/2] mgr/telemetry: anonymizing smartctl report itself smartctl JSON output contains the device's serial number in two different keys ('serial_number' & 'output'). Serial is now obfuscated in both. Fixes: https://tracker.ceph.com/issues/43939 Signed-off-by: Yaarit Hatuka --- src/pybind/mgr/telemetry/module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index ce8dd71e51a..e782d01732e 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -395,9 +395,9 @@ class Module(MgrModule): host, anon_host)) # anonymize the smartctl report itself - for k in ['serial_number']: - if k in m: - m.pop(k) + serial = devid.rsplit('_', 1)[1] + m_str = json.dumps(m) + m = json.loads(m_str.replace(serial, 'deleted')) if anon_host not in res: res[anon_host] = {}