From 4a9693412e4046747141f3a1945ced1c3b15a848 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 16 Jun 2023 08:41:23 +1000 Subject: [PATCH] add cli fuzziness option --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index eab241d..e30f1aa 100644 --- a/main.go +++ b/main.go @@ -214,6 +214,7 @@ func main() { vInsecure := flag.Bool("insecure", true, "Allow insecure connections to vCenter") 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") flag.Parse() // Print logs to file @@ -281,7 +282,7 @@ func main() { vmRestartTime := event.CreatedTime.In(location) // 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(5 * time.Minute) + fuzzyTime := vmRestartTime.Add(time.Duration(int(time.Minute) * int(*fuzzyMinutes))) log.Printf("Failure event for VM '%s' restarted in cluster '%s'\n", event.Vm.Name, event.ComputeResource.Name) // Get a reference to the cluster mentioned