diff --git a/main.go b/main.go index 7ae7d2b..fa6fbf4 100644 --- a/main.go +++ b/main.go @@ -311,7 +311,7 @@ func main() { // Sometimes host HA events can come through a few minutes after a VM restart event, so create a "fuzzy" starting time to search for host HA events fuzzyTime := vmRestartTime.Add(time.Duration(int64(time.Minute) * int64(*fuzzyMinutes))) - log.Printf("Failure event for VM '%s' restarted in cluster '%s'\n", event.Vm.Name, event.ComputeResource.Name) + log.Printf("Failure event for VM '%s' restarted in cluster '%s' at %s\n", event.Vm.Name, event.ComputeResource.Name, event.CreatedTime.In(location).Format(time.ANSIC)) // Get a reference to the cluster mentioned cluster := getCluster((event.ComputeResource.Name)) @@ -351,7 +351,7 @@ func main() { 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 { + for _, hostEvent := range haUnreachableEvents { if hostEvent.CreatedTime.In(location).Before(fuzzyTime) || hostEvent.CreatedTime.In(location).Equal(fuzzyTime) { possibleHosts = append(possibleHosts, hostEvent) } @@ -365,7 +365,7 @@ func main() { } } } else { // Didn't find any VM disconnected events - log.Printf("could not determine previous host for this VM. Filtering all host failures for events prior to fuzzy VM restart time '%s'\n", fuzzyTime) + log.Printf("could not determine previous host for this VM. Filtering all ha unreachable events prior to fuzzy VM restart time '%s'\n", fuzzyTime) // TODO Use HA unreachable events to find the host for _, hostEvent := range haUnreachableEvents { @@ -383,7 +383,7 @@ func main() { */ log.Printf("Based on event times there were %d possible hosts this VM was running on\n", len(possibleHosts)) for _, hostEvent := range possibleHosts { - log.Printf("Host %s\n", hostEvent.Host.Name) + log.Printf("Host %s (%s)\n", hostEvent.Host.Name, hostEvent.CreatedTime.In(location).Format(time.ANSIC)) } if len(possibleHosts) == 0 { @@ -440,7 +440,7 @@ func main() { } else { // if using the actual VM restart time doesn't narrow things down then go back to using the last host failure time before the fuzzy VM restart time lastIndex := len(possibleHosts) - 1 - log.Printf("Failed host was '%s', using outage start time of '%s'\n", possibleHosts[lastIndex].Host.Name, possibleHosts[lastIndex].CreatedTime.In(location)) + log.Printf("Last failed host before restart time was '%s'. Using outage start time of '%s'\n", possibleHosts[lastIndex].Host.Name, possibleHosts[lastIndex].CreatedTime.In(location)) failedHost = possibleHosts[lastIndex].Host.Name outageStart = possibleHosts[lastIndex].CreatedTime.In(location) restartTime = vmRestartTime