code: def collect(self):
          
  
          if psutil is None:
              self.log.error('Unable to import module psutil')
              return {}
  
          for port_name, port_cfg in self.ports.iteritems():
              port = int(port_cfg['number'])
              stats = get_port_stats(port)
  
              for stat_name, stat_value in stats.iteritems():
                  metric_name = '%s.%s' % (port_name, stat_name)
                  self.publish(metric_name, stat_value)
docs: Overrides the Collector.collect method