diff --git a/main.go b/main.go index 0083997..5cda579 100644 --- a/main.go +++ b/main.go @@ -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) + } } }