filter ha unreachable to hosts that actually failed
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-03-18 10:28:33 +11:00
parent 6aa7627c96
commit fd23121a7c

19
main.go
View File

@@ -277,8 +277,23 @@ func main() {
for _, h := range haStatusChanges {
unreachableMessage := strings.Contains(strings.ToLower(h.FullFormattedMessage), "changed to unreachable")
if unreachableMessage {
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 this host was in the host failures list
hostFound := false
for _, f := range hostFailures {
if h.Host.Name == f.Host.Name {
// got it
hostFound = true
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)
} else {
log.Printf("Host %s was not found in the list of hostfailure events, skipping this host\n", h.Host.Name)
}
}
}