code: def collect(self):
          
          stats = self.parse_stats_file(self.config["status_path"])
          if len(stats) == 0:
              return {}
          elif "info" not in stats.keys():
              return {}
          elif "programstatus" not in stats.keys():
              return {}
  
          metrics = self.get_icinga_stats(stats["programstatus"])
          if "hoststatus" in stats.keys():
              metrics = dict(
                  metrics.items() + self.get_host_stats(
                      stats["hoststatus"]).items())
  
          if "servicestatus" in stats.keys():
              metrics = dict(
                  metrics.items() + self.get_svc_stats(
                      stats["servicestatus"]).items())
  
          for metric in metrics.keys():
              self.log.debug("Publishing '%s %s'.", metric, metrics[metric])
              self.publish(metric, metrics[metric])
docs: Collect and publish metrics