code: def collect(self):
          
          if not os.access(self.PROC, os.R_OK):
              return False
  
          # Open PROC file
          file = open(self.PROC, 'r')
  
          # Get data
          for line in file:
  
              if line.startswith('ctxt') or line.startswith('processes'):
                  data = line.split()
                  metric_name = data[0]
                  metric_value = int(data[1])
                  metric_value = int(self.derivative(metric_name,
                                                     long(metric_value),
                                                     counter))
                  self.publish(metric_name, metric_value)
  
              if line.startswith('procs_') or line.startswith('btime'):
                  data = line.split()
                  metric_name = data[0]
                  metric_value = int(data[1])
                  self.publish(metric_name, metric_value)
  
          # Close file
          file.close()
docs: Collect process stat data