Merge branch 'main' of https://git.coadcorp.com/nathan/go-events
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-04-29 16:58:14 +10:00

View File

@@ -216,6 +216,7 @@ func main() {
begin := flag.Duration("b", time.Hour, "Begin time") // default BeginTime is 1h ago
end := flag.Duration("e", 0, "End time")
fuzzyMinutes := flag.Int("fuzziness", 5, "Number of minutes to offset VM restart time when searching for related Host failure event")
unreachableMinutes := flag.Int("unreachable", 20, "Number of minutes to search for host HA events either side of a VM failure")
flag.Parse()
// Print logs to file
@@ -277,7 +278,8 @@ func main() {
// filter ha status changed messages for unreachable ones
for _, h := range haStatusChanges {
unreachableMessage := strings.Contains(strings.ToLower(h.FullFormattedMessage), "changed to unreachable")
if unreachableMessage {
hostFailedMessage := strings.Contains(strings.ToLower(h.FullFormattedMessage), "changed to host failed")
if unreachableMessage || hostFailedMessage {
// make sure this host was in the host failures list
hostFound := false
@@ -293,8 +295,8 @@ func main() {
// make sure that this event is within 10 minutes either side of the corresponding host failed event
if hostFound {
unreachableStartComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * -10))
unreachableEndComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * 10))
unreachableStartComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * -1 * int64(*unreachableMinutes)))
unreachableEndComparison := h.CreatedTime.In(location).Add(time.Duration(int64(time.Minute) * int64(*unreachableMinutes)))
if haFailedTime.Before(unreachableEndComparison) && haFailedTime.After(unreachableStartComparison) {
haUnreachableEvents = append(haUnreachableEvents, h)