]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: include device telemetry
authorSage Weil <sage@redhat.com>
Fri, 4 Oct 2019 20:03:53 +0000 (15:03 -0500)
committerSage Weil <sage@redhat.com>
Thu, 10 Oct 2019 02:30:13 +0000 (21:30 -0500)
- anonymize device id
- anonymize host names
- strip out the serial number

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/devicehealth/module.py
src/pybind/mgr/telemetry/module.py

index 1955bec661e7195144fdd2ecd147405c5f536925..78bbc3166755fc037619089d01548e8004417f60 100644 (file)
@@ -641,6 +641,8 @@ class Module(MgrModule):
         except:
             return -1, '', 'unable to invoke diskprediction local or remote plugin'
 
-    def gather_device_report(self):
-        # write me
-        return {}
+    def get_recent_device_metrics(self, devid, min_sample):
+        return self._get_device_metrics(devid, min_sample=min_sample)
+
+    def get_time_format(self):
+        return TIME_FORMAT
index 769fc72bc62a5a5fe9c410c5247ceccd895b498c..8a260b27176cdf1aa9f1a1e17b92601a1c037bdf 100644 (file)
@@ -11,7 +11,7 @@ import re
 import requests
 import uuid
 import time
-from datetime import datetime
+from datetime import datetime, timedelta
 from threading import Event
 from collections import defaultdict
 
@@ -129,7 +129,7 @@ class Module(MgrModule):
             'name': 'channel_device',
             'type': 'bool',
             'default': True,
-            'description': 'Share device health metrics (e.g., SMART data)',
+            'description': 'Share device health metrics (e.g., SMART data, minus potentially identifying info like serial numbers)',
         },
     ]
 
@@ -293,9 +293,50 @@ class Module(MgrModule):
 
     def gather_device_report(self):
         try:
-            return self.remote('devicehealth', 'gather_device_report')
+            time_format = self.remote('devicehealth', 'get_time_format')
         except:
             return None
+        cutoff = datetime.utcnow() - timedelta(hours=self.interval * 2)
+        min_sample = cutoff.strftime(time_format)
+
+        devices = self.get('devices')['devices']
+
+        res = {}
+        for d in devices:
+            devid = d['devid']
+            try:
+                m = self.remote('devicehealth', 'get_recent_device_metrics',
+                                devid, min_sample)
+            except:
+                continue
+
+            # anonymize host id
+            try:
+                host = d['location'][0]['host']
+            except:
+                continue
+            anon_host = self.get_store('host-id/%s' % host)
+            if not anon_host:
+                anon_host = str(uuid.uuid1())
+                self.set_store('host-id/%s' % host, anon_host)
+            m['host_id'] = anon_host
+
+            # anonymize device id
+            (vendor, model, serial) = devid.split('_')
+            anon_devid = self.get_store('devid-id/%s' % devid)
+            if not anon_devid:
+                anon_devid = '%s_%s_%s' % (vendor, model, uuid.uuid1())
+                self.set_store('devid-id/%s' % devid, anon_devid)
+
+            self.log.info('devid %s / %s, host %s / %s' % (devid, anon_devid,
+                                                           host, anon_host))
+
+            # anonymize the smartctl report itself
+            for k in ['serial_number']:
+                m.pop(k)
+
+            res[anon_devid] = m
+        return res
 
     def compile_report(self, channels=[]):
         if not channels: