def Collect(self):
    """Collects the stats."""

    user, system = self.proc.cpu_times()
    percent = self.proc.cpu_percent()
    self.cpu_samples.append((rdfvalue.RDFDatetime().Now(),
                             user, system, percent))
    # Keep stats for one hour.
    self.cpu_samples = self.cpu_samples[-3600 / self.sleep_time:]

    # Not supported on MacOS.
    try:
      _, _, read_bytes, write_bytes = self.proc.io_counters()
      self.io_samples.append((rdfvalue.RDFDatetime().Now(),
                              read_bytes, write_bytes))
      self.io_samples = self.io_samples[-3600 / self.sleep_time:]
    except (AttributeError, __HOLE__, psutil.Error):
      pass
dataset/ETHPy150Open google/grr/grr/client/client_stats.py/ClientStatsCollector.Collect