output results
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-05-23 15:14:32 +10:00
parent 48a1da8d24
commit 1a67dfc8e9

23
main.go
View File

@@ -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
@@ -322,12 +323,16 @@ func main() {
// Create a new result
result := OutageResults{
VM: event.Vm.Name,
OutageDuration: out.Format("15:04:05"),
OutageStart: outageStart,
RestartTime: restartTime,
ComputeResource: event.ComputeResource.Name,
FailedHost: failedHost,
VM: event.Vm.Name,
OutageDuration: out.Format("15:04:05"),
OutageStart: outageStart,
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))
}