code: func (a *Agent) loadCheckState(check *structs.HealthCheck) error {
  	// Try to read the persisted state for this check
  	file := filepath.Join(a.config.DataDir, checkStateDir, checkIDHash(check.CheckID))
  	buf, err := ioutil.ReadFile(file)
  	if err != nil {
  		if os.IsNotExist(err) {
  			return nil
  		}
  		return fmt.Errorf("failed reading file %q: %s", file, err)
  	}
  
  	// Decode the state data
  	var p persistedCheckState
  	if err := json.Unmarshal(buf, &p); err != nil {
  		a.logger.Printf("[ERR] agent: failed decoding check state: %s", err)
  		return a.purgeCheckState(check.CheckID)
  	}
  
  	// Check if the state has expired
  	if time.Now().Unix() >= p.Expires {
  		a.logger.Printf("[DEBUG] agent: check state expired for %q, not restoring", check.CheckID)
  		return a.purgeCheckState(check.CheckID)
  	}
  
  	// Restore the fields from the state
  	check.Output = p.Output
  	check.Status = p.Status
  	return nil
  }
docs: // loadCheckState is used to restore the persisted state of a check.