test
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-03-18 11:11:31 +11:00
parent 328b027fdc
commit f20712beb0

17
main.go
View File

@@ -280,17 +280,30 @@ func main() {
// make sure this host was in the host failures list
hostFound := false
var haFailedTime time.Time
for _, f := range hostFailures {
if h.Host.Name == f.Host.Name {
// got it
hostFound = true
haFailedTime = f.CreatedTime.In(location)
break
}
}
if hostFound {
haUnreachableEvents = append(haUnreachableEvents, h)
log.Printf("Host %s unreachable HA status event at %s : '%s'\n", h.Host.Name, h.CreatedTime.In(location).Format(time.ANSIC), h.FullFormattedMessage)
// make sure that this event is within 15 minutes of the corresponding host failed event
unreachableStartComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * -15))
unreachableEndComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * 15))
if haFailedTime.Before(unreachableEndComparison) && haFailedTime.After(unreachableStartComparison) {
haUnreachableEvents = append(haUnreachableEvents, h)
log.Printf("Host %s unreachable HA status event at %s : '%s'\n", h.Host.Name, h.CreatedTime.In(location).Format(time.ANSIC), h.FullFormattedMessage)
} else {
log.Printf("Host %s unreachable HA status event at %s was before %s or after %s\n", h.Host.Name, h.CreatedTime.In(location).Format(time.ANSIC),
unreachableStartComparison, unreachableEndComparison)
}
} else {
log.Printf("Host %s was not found in the list of hostfailure events, skipping this host\n", h.Host.Name)
}