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

This commit is contained in:
2023-05-26 11:49:33 +10:00
parent fbf795b586
commit e4448239e2

20
main.go
View File

@@ -304,6 +304,26 @@ func main() {
possibleHosts = append(possibleHosts, e)
}
}
log.Printf("After filtering there are %d events\n", len(possibleHosts))
// Its possible that the VM disconnected messages dont' relate to the host HA events that we found
// If that is the case then we fall back to the most recent host failure message in our list
if len(possibleHosts) == 0 {
log.Printf("No corresponding VM disconnected messages, falling back to any applicable host that experienced a HA event.\n")
// Search for host failures
for _, hostEvent := range hostFailures {
if hostEvent.CreatedTime.In(location).Before(vmRestartTime) || hostEvent.CreatedTime.In(location).Equal(vmRestartTime) {
possibleHosts = append(possibleHosts, hostEvent)
}
}
log.Printf("Based on event times there were %d possible hosts this VM was running on\n", len(possibleHosts))
if len(possibleHosts) == 0 {
log.Printf("No ESXi outage events happened before VM %s restart event at %s, skipping this event.\n", event.Vm.Name, vmRestartTime)
continue
}
}
/*
disconnectedHost := disconnectedEvents[0]