This commit is contained in:
davidnewhall2 2020-06-21 12:22:01 -07:00
parent 5f5b4c4f6a
commit 6d9dd6d4cb
1 changed files with 11 additions and 8 deletions

View File

@ -83,10 +83,7 @@ func (u *InputUnifi) collectController(c *Controller) (*poller.Metrics, error) {
} }
func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]interface{}, error) { func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]interface{}, error) {
var ( logs := []interface{}{}
l interface{}
logs []interface{}
)
// Get the sites we care about. // Get the sites we care about.
sites, err := u.getFilteredSites(c) sites, err := u.getFilteredSites(c)
@ -95,19 +92,25 @@ func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]i
} }
if *c.SaveEvents { if *c.SaveEvents {
if l, err = c.Unifi.GetEvents(sites, from); err != nil { events, err := c.Unifi.GetEvents(sites, from)
if err != nil {
return nil, errors.Wrap(err, "unifi.GetEvents()") return nil, errors.Wrap(err, "unifi.GetEvents()")
} }
logs = append(logs, l) for _, e := range events {
logs = append(logs, redactEvent(e, c.HashPII))
}
} }
if *c.SaveIDS { if *c.SaveIDS {
if l, err = c.Unifi.GetIDS(sites, from); err != nil { events, err := c.Unifi.GetIDS(sites, from)
if err != nil {
return nil, errors.Wrap(err, "unifi.GetIDS()") return nil, errors.Wrap(err, "unifi.GetIDS()")
} }
logs = append(logs, l) for _, e := range events {
logs = append(logs, e)
}
} }
return logs, nil return logs, nil