From 4db4df9e467b65a435070f40de37f13af326db03 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Sun, 2 Feb 2020 00:49:56 -0800 Subject: [PATCH] more fixes --- integrations/inputunifi/collector.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/integrations/inputunifi/collector.go b/integrations/inputunifi/collector.go index 37699823..0bcb3966 100644 --- a/integrations/inputunifi/collector.go +++ b/integrations/inputunifi/collector.go @@ -64,7 +64,16 @@ func (u *InputUnifi) collectController(c *Controller) (*poller.Metrics, error) { } } - return u.pollController(c) + metrics, err := u.pollController(c) + if err != nil { + u.Logf("Re-authenticating to UniFi Controller: %s", c.URL) + + if err := u.getUnifi(c); err != nil { + return metrics, fmt.Errorf("re-authenticating to %s: %v", c.Role, err) + } + } + + return metrics, err } func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) { @@ -77,10 +86,7 @@ func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) { // Get the sites we care about. if m.Sites, err = u.getFilteredSites(c); err != nil { - err = fmt.Errorf("unifi.GetSites(%v): %v", c.URL, err) - c = nil // reset for next time, so it will re-auth. - - return nil, err + return nil, fmt.Errorf("unifi.GetSites(): %v", err) } if c.SaveDPI {