From 9992ff2db88552ed1d5cd5f96df18d663f2d8c58 Mon Sep 17 00:00:00 2001 From: Nathan Hemingway Date: Tue, 16 Feb 2021 10:28:26 -0800 Subject: [PATCH] + faults-only option for only monitoring faults --- main.go | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index f6662a7..bd91443 100644 --- a/main.go +++ b/main.go @@ -739,17 +739,19 @@ func getFabric() fabricObject { log.Error(err) continue } - if devices, err = getDevices(); err != nil { - log.Error(err) - continue - } - if pods, err = getPods(); err != nil { - log.Error(err) - continue - } - if isisRoutes, err = getISISRoutes(pods); err != nil { - log.Error(err) - continue + if !client.cfg.FaultsOnly { + if devices, err = getDevices(); err != nil { + log.Error(err) + continue + } + if pods, err = getPods(); err != nil { + log.Error(err) + continue + } + if isisRoutes, err = getISISRoutes(pods); err != nil { + log.Error(err) + continue + } } ok = true } @@ -822,6 +824,7 @@ type Config struct { Password string `arg:"-p" help:"password"` Snapshot string `arg:"-s" help:"Snapshot file"` Verbose bool `arg:"-v"` + FaultsOnly bool `arg:"--faults-only" help:"Only monitor faults"` RequestTimeout int `arg:"--request-timeout" help:"HTTP request timeout"` LoginRetryInterval int `arg:"--login-retry-interval" help:"Login retry interval"` } @@ -865,22 +868,30 @@ func requestLoop(fabric fabricObject) error { return err } } - statuses, err := getUpgradeStatuses(fabric.devices) - if err != nil { - return err - } - if verifyUpgradeState(statuses) == stable { + if client.cfg.FaultsOnly { currentFaults, err := getFaults() if err != nil { return err } verifyFaults(fabric.faults, currentFaults) - if len(fabric.pods) > 1 { - isisRoutes, err := getISISRoutes(fabric.pods) + } else { + statuses, err := getUpgradeStatuses(fabric.devices) + if err != nil { + return err + } + if verifyUpgradeState(statuses) == stable { + currentFaults, err := getFaults() if err != nil { return err } - verifyInterpodRoutes(fabric, isisRoutes) + verifyFaults(fabric.faults, currentFaults) + if len(fabric.pods) > 1 { + isisRoutes, err := getISISRoutes(fabric.pods) + if err != nil { + return err + } + verifyInterpodRoutes(fabric, isisRoutes) + } } } log.Info("Sleeping for 10 seconds...")