This commit is contained in:
17
main.go
17
main.go
@@ -280,17 +280,30 @@ func main() {
|
|||||||
|
|
||||||
// make sure this host was in the host failures list
|
// make sure this host was in the host failures list
|
||||||
hostFound := false
|
hostFound := false
|
||||||
|
var haFailedTime time.Time
|
||||||
for _, f := range hostFailures {
|
for _, f := range hostFailures {
|
||||||
if h.Host.Name == f.Host.Name {
|
if h.Host.Name == f.Host.Name {
|
||||||
// got it
|
// got it
|
||||||
hostFound = true
|
hostFound = true
|
||||||
|
haFailedTime = f.CreatedTime.In(location)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if hostFound {
|
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 {
|
} else {
|
||||||
log.Printf("Host %s was not found in the list of hostfailure events, skipping this host\n", h.Host.Name)
|
log.Printf("Host %s was not found in the list of hostfailure events, skipping this host\n", h.Host.Name)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user