This commit is contained in:
11
main.go
11
main.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/url"
|
||||
@@ -287,7 +288,7 @@ func main() {
|
||||
|
||||
if len(possibleHosts) == 1 {
|
||||
fmt.Printf("Found a single host failure event relating to VM %s\n", event.Vm.Name)
|
||||
fmt.Printf("Failed host was '%s', using outage start time of '%s'", possibleHosts[0].Host.Name, possibleHosts[0].CreatedTime.In(location))
|
||||
fmt.Printf("Failed host was '%s', using outage start time of '%s'\n", possibleHosts[0].Host.Name, possibleHosts[0].CreatedTime.In(location))
|
||||
failedHost = possibleHosts[0].Host.Name
|
||||
outageStart = possibleHosts[0].CreatedTime.In(location)
|
||||
restartTime = vmRestartTime
|
||||
@@ -297,7 +298,7 @@ func main() {
|
||||
// possible hosts is sorted by time, so use the last value if there are multiple
|
||||
lastIndex := len(possibleHosts) - 1
|
||||
|
||||
fmt.Printf("Failed host was '%s', using outage start time of '%s'", possibleHosts[lastIndex].Host.Name, possibleHosts[lastIndex].CreatedTime.In(location))
|
||||
fmt.Printf("Failed host 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
|
||||
@@ -328,6 +329,10 @@ func main() {
|
||||
RestartTime: restartTime,
|
||||
ComputeResource: event.ComputeResource.Name,
|
||||
FailedHost: failedHost,
|
||||
NewHost: event.Host.Name,
|
||||
GuestOS: vm.Summary.Guest.GuestFullName,
|
||||
CurrentPowerState: string(vm.Summary.Runtime.PowerState),
|
||||
Description: event.FullFormattedMessage,
|
||||
}
|
||||
// Append to list of all results
|
||||
results = append(results, result)
|
||||
@@ -335,4 +340,6 @@ func main() {
|
||||
}
|
||||
|
||||
// Output final results in JSON
|
||||
j, _ := json.Marshal(results)
|
||||
fmt.Println(string(j))
|
||||
}
|
||||
|
Reference in New Issue
Block a user