code: def parse_mntr(self, buf):
          
          buf.seek(0)
          first = buf.readline()  # First is version string or error
          if first == 'This ZooKeeper instance is not currently serving requests':
              return (None, 'inactive')
  
          metrics = []
          mode = 'inactive'
  
          for line in buf:
              try:
                  key, value = line.split()
  
                  if key == "zk_server_state":
                      mode = value.lower()
                      continue
  
                  metric_name = self._normalize_metric_label(key)
                  metric_type = "rate" if key in self._MNTR_RATES else "gauge"
                  metric_value = int(value)
                  metrics.append(ZKMetric(metric_name, metric_value, metric_type))
  
              except ValueError:
                  self.log.warning(u"Cannot format `mntr` value. key={key}, value{value}".format(key=key, value=value))
                  continue
              except Exception:
                  self.log.exception(
                      u"Unexpected exception occurred while parsing `mntr` command content:\n{buf}".format(buf=buf)
                  )
  
          return (metrics, mode)
docs: Parse `mntr` command's content.
          `buf` is a readable file-like object
  
          Returns: a tuple (metrics, mode)
          if mode == 'inactive', metrics will be None