Add duration parsing for intervals

This commit is contained in:
Ian Fijolek
2021-05-10 21:39:52 -07:00
parent befea7375f
commit bdf7355fa7
4 changed files with 9 additions and 10 deletions
+4 -4
View File
@@ -11,9 +11,9 @@ import (
// Monitor represents a particular periodic check of a command
type Monitor struct { //nolint:maligned
// Config values
AlertAfter int16 `yaml:"alert_after"`
AlertEvery int16 `yaml:"alert_every"`
CheckInterval float64 `yaml:"check_interval"`
AlertAfter int16 `yaml:"alert_after"`
AlertEvery int16 `yaml:"alert_every"`
CheckInterval time.Duration `yaml:"check_interval"`
Name string
AlertDown []string `yaml:"alert_down"`
AlertUp []string `yaml:"alert_up"`
@@ -43,7 +43,7 @@ func (monitor Monitor) ShouldCheck() bool {
return true
}
sinceLastCheck := time.Since(monitor.lastCheck).Seconds()
sinceLastCheck := time.Since(monitor.lastCheck)
return sinceLastCheck >= monitor.CheckInterval
}