From 7587a390fb3a56a4a702015e08a1c83ed1dcd39e Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Mon, 22 Jun 2020 00:05:12 -0700 Subject: [PATCH] count events and ids indivually. --- integrations/influxunifi/influxdb.go | 6 ++++-- integrations/influxunifi/report.go | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/integrations/influxunifi/influxdb.go b/integrations/influxunifi/influxdb.go index 6a26b01a..b283d590 100644 --- a/integrations/influxunifi/influxdb.go +++ b/integrations/influxunifi/influxdb.go @@ -264,8 +264,10 @@ func (u *InfluxUnifi) switchExport(r report, v interface{}) { case *unifi.Client: u.batchClient(r, v) case *unifi.Event: + r.addEvent() u.batchEvent(r, v) case *unifi.IDS: + r.addIDS() u.batchIDS(r, v) default: u.Collector.LogErrorf("invalid export type: %T", v) @@ -276,9 +278,9 @@ func (u *InfluxUnifi) switchExport(r report, v interface{}) { func (u *InfluxUnifi) LogInfluxReport(r *Report) { m := r.Metrics u.Collector.Logf("UniFi Metrics Recorded. Sites: %d, Clients: %d, "+ - "UAP: %d, USG/UDM: %d, USW: %d, IDS+Events: %d, Points: %d, "+ + "UAP: %d, USG/UDM: %d, USW: %d, IDS/Events: %d/%d, Points: %d, "+ "Fields: %d, Errs: %d, Elapsed: %v", len(m.Sites), len(m.Clients), r.UAP, r.UDM+r.USG, - r.USW, len(r.Events.Logs), r.Total, + r.USW, r.IDS, r.Eve, r.Total, r.Fields, len(r.Errors), r.Elapsed.Round(time.Millisecond)) } diff --git a/integrations/influxunifi/report.go b/integrations/influxunifi/report.go index ca41932b..3ee01516 100644 --- a/integrations/influxunifi/report.go +++ b/integrations/influxunifi/report.go @@ -19,6 +19,8 @@ type Report struct { USW int // Total count of USW devices. UAP int // Total count of UAP devices. UDM int // Total count of UDM devices. + Eve int // Total count of Events. + IDS int // Total count of IDS/IPS Events. Start time.Time Elapsed time.Duration ch chan *metric @@ -39,6 +41,8 @@ type report interface { addUSG() addUAP() addUSW() + addEvent() + addIDS() } func (r *Report) metrics() *poller.Metrics { @@ -67,18 +71,21 @@ func (r *Report) send(m *metric) { func (r *Report) addUSW() { r.USW++ } - func (r *Report) addUAP() { r.UAP++ } - func (r *Report) addUSG() { r.USG++ } - func (r *Report) addUDM() { r.UDM++ } +func (r *Report) addEvent() { + r.Eve++ +} +func (r *Report) addIDS() { + r.IDS++ +} func (r *Report) error(err error) { if err != nil {