code: def collect(self):
          
          def traverse(d, metric_name=''):
              """
              Traverse the given nested dict using depth-first search.
  
              If a value is reached it will be published with a metric name
              consisting of the hierarchically concatenated keys
              of its branch.
              """
              for key, value in d.iteritems():
                  if isinstance(value, dict):
                      if metric_name == '':
                          metric_name_next = key
                      else:
                          metric_name_next = metric_name + '.' + key
                      traverse(value, metric_name_next)
                  else:
                      metric_name_finished = metric_name + '.' + key
                      self.publish_gauge(
                          name=metric_name_finished,
                          value=value,
                          precision=1
                      )
  
          md_state = self._parse_mdstat()
  
          traverse(md_state, '')
docs: Publish all mdstat metrics.