go back 1 hour
This commit is contained in:
parent
3c58f883f9
commit
f73bed4142
|
|
@ -82,7 +82,7 @@ func (u *InputUnifi) collectController(c *Controller) (*poller.Metrics, error) {
|
|||
return metrics, err
|
||||
}
|
||||
|
||||
func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]interface{}, error) {
|
||||
func (u *InputUnifi) collectControllerEvents(c *Controller) ([]interface{}, error) {
|
||||
logs := []interface{}{}
|
||||
|
||||
// Get the sites we care about.
|
||||
|
|
@ -92,7 +92,7 @@ func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]i
|
|||
}
|
||||
|
||||
if *c.SaveEvents {
|
||||
events, err := c.Unifi.GetEvents(sites, from)
|
||||
events, err := c.Unifi.GetEvents(sites, time.Hour)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unifi.GetEvents()")
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ func (u *InputUnifi) collectControllerEvents(c *Controller, from time.Time) ([]i
|
|||
}
|
||||
|
||||
if *c.SaveIDS {
|
||||
events, err := c.Unifi.GetIDS(sites, from)
|
||||
events, err := c.Unifi.GetIDS(sites, time.Now().Add(-time.Hour))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unifi.GetIDS()")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ go 1.14
|
|||
require (
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/unifi-poller/poller v0.0.8-0.20200621214016-5d1ed3324a46
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200621075746-253ccae7e106
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200622073824-4a29471d80f6
|
||||
)
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ github.com/unifi-poller/poller v0.0.8-0.20200621214016-5d1ed3324a46/go.mod h1:pJ
|
|||
github.com/unifi-poller/unifi v0.0.5-0.20200620103801-b927287ea1cd/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8=
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200621075746-253ccae7e106 h1:eKErSqWD656pLSWgxFwhDhHe/zfAXrm7F39Zn4R+si8=
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200621075746-253ccae7e106/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8=
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200622073824-4a29471d80f6 h1:KzQDaEhDxtDzoyfBPXzM/pwpD76+4Y74Y66XMhKt2pI=
|
||||
github.com/unifi-poller/unifi v0.0.5-0.20200622073824-4a29471d80f6/go.mod h1:L1kMRH2buZhB31vZnRC1im7Tk/4uD3ET4biwl2faYy8=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/unifi-poller/poller"
|
||||
|
|
@ -79,7 +78,6 @@ func (u *InputUnifi) logController(c *Controller) {
|
|||
// Events allows you to pull only events (and IDS) from the UniFi Controller.
|
||||
// This does not fully respect HashPII, but it may in the future!
|
||||
// Use Filter.Path to pick a specific controller, otherwise poll them all!
|
||||
// Use Filter.Dur to set a search duration into the past; 1 minute default.
|
||||
func (u *InputUnifi) Events(filter *poller.Filter) (*poller.Events, error) {
|
||||
if u.Disable {
|
||||
return nil, nil
|
||||
|
|
@ -87,8 +85,8 @@ func (u *InputUnifi) Events(filter *poller.Filter) (*poller.Events, error) {
|
|||
|
||||
logs := []interface{}{}
|
||||
|
||||
if filter == nil || filter.Dur == 0 {
|
||||
filter = &poller.Filter{Dur: time.Minute}
|
||||
if filter == nil {
|
||||
filter = &poller.Filter{}
|
||||
}
|
||||
|
||||
for _, c := range u.Controllers {
|
||||
|
|
@ -96,7 +94,7 @@ func (u *InputUnifi) Events(filter *poller.Filter) (*poller.Events, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
events, err := u.collectControllerEvents(c, time.Now().Add(-filter.Dur))
|
||||
events, err := u.collectControllerEvents(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue