This commit is contained in:
David Newhall II 2021-03-07 21:49:21 -08:00
parent cccad3d347
commit 44eec5aaf0
6 changed files with 13 additions and 12 deletions

View File

@ -1,9 +1,9 @@
language: go
go:
- 1.14.x
- 1.15.x
before_install:
# download super-linter: golangci-lint
- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
script:
- go test ./...
- golangci-lint run --enable-all
- golangci-lint run --enable-all -D exhaustivestruct,nlreturn

View File

@ -12,7 +12,7 @@ const (
)
// batchAlarms generates alarm datapoints for InfluxDB.
func (u *InfluxUnifi) batchAlarms(r report, event *unifi.Alarm) { // nolint: godupl
func (u *InfluxUnifi) batchAlarms(r report, event *unifi.Alarm) { // nolint:dupl
if time.Since(event.Datetime) > u.Interval.Duration+time.Second {
return // The event is older than our interval, ignore it.
}

View File

@ -103,8 +103,8 @@ func (u *InfluxUnifi) batchClientDPI(r report, v interface{}, appTotal, catTotal
"rx_packets": dpi.RxPackets,
"tx_bytes": dpi.TxBytes,
"rx_bytes": dpi.RxBytes,
}},
)
},
})
}
}

View File

@ -13,7 +13,7 @@ const (
)
// batchIDS generates intrusion detection datapoints for InfluxDB.
func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) { // nolint: godupl
func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) { // nolint:dupl
if time.Since(i.Datetime) > u.Interval.Duration+time.Second {
return // The event is older than our interval, ignore it.
}
@ -157,7 +157,7 @@ func cleanTags(tags map[string]string) map[string]string {
}
// cleanFields removes any field with a default (or empty) value.
func cleanFields(fields map[string]interface{}) map[string]interface{} {
func cleanFields(fields map[string]interface{}) map[string]interface{} { //nolint:cyclop
for s := range fields {
switch v := fields[s].(type) {
case nil:

View File

@ -4,6 +4,7 @@ package influxunifi
import (
"crypto/tls"
"fmt"
"io/ioutil"
"log"
"strconv"
@ -19,7 +20,7 @@ import (
)
// PluginName is the name of this plugin.
const PluginName = "InfluxDB"
const PluginName = "influxdb"
const (
defaultInterval = 30 * time.Second
@ -119,7 +120,7 @@ func (u *InfluxUnifi) Run(c poller.Collect) error {
TLSConfig: &tls.Config{InsecureSkipVerify: !u.VerifySSL}, // nolint: gosec
})
if err != nil {
return err
return fmt.Errorf("making client: %w", err)
}
fake := *u.Config
@ -259,7 +260,7 @@ func (u *InfluxUnifi) loopPoints(r report) {
reportClientDPItotals(r, appTotal, catTotal)
}
func (u *InfluxUnifi) switchExport(r report, v interface{}) {
func (u *InfluxUnifi) switchExport(r report, v interface{}) { //nolint:cyclop
switch v := v.(type) {
case *unifi.UAP:
u.batchUAP(r, v)

View File

@ -78,7 +78,7 @@ func (u *InfluxUnifi) batchSiteDPI(r report, v interface{}) {
"rx_packets": dpi.RxPackets,
"tx_bytes": dpi.TxBytes,
"rx_bytes": dpi.RxBytes,
}},
)
},
})
}
}