code: def do_check_freshness(self, hosts, services, timeperiods, macromodulations, checkmodulations,
                             checks, when):
          now = when
          cls = self.__class__
          if not self.in_checking and self.freshness_threshold and not self.freshness_expired:
              if os.getenv('ALIGNAK_LOG_CHECKS', None):
                  logger.info("--ALC-- -> checking freshness for: %s", self.get_full_name())
              if not self.last_state_update:
                  self.last_state_update = int(now)
              if self.last_state_update < now - \
                      (self.freshness_threshold + cls.additional_freshness_latency):
                  timeperiod = timeperiods[self.check_period]
                  if timeperiod is None or timeperiod.is_time_valid(now):
                      chk = self.launch_check(now, hosts, services, timeperiods,
                                              macromodulations, checkmodulations, checks)
                      if not chk:
                          logger.warning("No raised freshness check for: %s", self)
                          return None
                      chk.freshness_expiry_check = True
                      chk.check_time = time.time()
                      chk.output = "Freshness period expired: %s" % (
                          datetime.utcfromtimestamp(int(chk.check_time)).strftime(
                              "%Y-%m-%d %H:%M:%S %Z"))
                      if self.my_type == 'host':
                          if self.freshness_state == 'o':
                              chk.exit_status = 0
                          elif self.freshness_state == 'd':
                              chk.exit_status = 2
                          elif self.freshness_state in ['u', 'x']:
                              chk.exit_status = 4
                          else:
                              chk.exit_status = 3
                      else:
                          if self.freshness_state == 'o':
                              chk.exit_status = 0
                          elif self.freshness_state == 'w':
                              chk.exit_status = 1
                          elif self.freshness_state == 'c':
                              chk.exit_status = 2
                          elif self.freshness_state == 'u':
                              chk.exit_status = 3
                          elif self.freshness_state == 'x':
                              chk.exit_status = 4
                          else:
                              chk.exit_status = 3
                      return chk
                  else:
                      logger.debug("Ignored freshness check for %s, because "
                                   "we are not in the check period.", self.get_full_name())
          return None