auto fix lint rules

This commit is contained in:
Cody Lee
2024-09-09 08:55:12 -05:00
parent 45a9e0d1eb
commit 9bdc6e8d0f
11 changed files with 48 additions and 48 deletions

View File

@@ -9,11 +9,11 @@ import (
// These constants are used as names for printed/logged counters.
const (
eventT = item("Event")
idsT = item("IDS")
idsT = item("IDs")
)
// batchIDS generates intrusion detection datapoints for InfluxDB.
func (u *InfluxUnifi) batchIDS(r report, i *unifi.IDS) { // nolint:dupl
// batchIDs generates intrusion detection datapoints for InfluxDB.
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.
}

View File

@@ -103,11 +103,11 @@ func (u *InfluxUnifi) PollController() {
interval := u.Interval.Round(time.Second)
ticker := time.NewTicker(interval)
version := "1"
if u.IsVersion2 {
version = "2"
}
u.Logf("Poller->InfluxDB started, version: %s, interval: %v, dp: %v, db: %s, url: %s, bucket: %s, org: %s",
version, interval, u.DeadPorts, u.DB, u.URL, u.Bucket, u.Org)
@@ -120,7 +120,7 @@ func (u *InfluxUnifi) Poll(interval time.Duration) {
metrics, err := u.Collector.Metrics(&poller.Filter{Name: "unifi"})
if err != nil {
u.LogErrorf("metric fetch for InfluxDB failed: %v", err)
return
}
@@ -146,11 +146,11 @@ func (u *InfluxUnifi) Enabled() bool {
if u == nil {
return false
}
if u.Config == nil {
return false
}
return !u.Disable
}
@@ -158,13 +158,13 @@ func (u *InfluxUnifi) DebugOutput() (bool, error) {
if u == nil {
return true, nil
}
if !u.Enabled() {
return true, nil
}
u.setConfigDefaults()
_, err := url.Parse(u.Config.URL)
if err != nil {
return false, fmt.Errorf("invalid influx URL: %v", err)
@@ -175,7 +175,7 @@ func (u *InfluxUnifi) DebugOutput() (bool, error) {
tlsConfig := &tls.Config{InsecureSkipVerify: !u.VerifySSL} // nolint: gosec
serverOptions := influx.DefaultOptions().SetTLSConfig(tlsConfig).SetBatchSize(u.BatchSize)
u.InfluxV2Client = influx.NewClientWithOptions(u.URL, u.AuthToken, serverOptions)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel()
@@ -210,7 +210,7 @@ func (u *InfluxUnifi) DebugOutput() (bool, error) {
// Run runs a ticker to poll the unifi server and update influxdb.
func (u *InfluxUnifi) Run(c poller.Collect) error {
u.Collector = c
if !u.Enabled() {
u.LogDebugf("InfluxDB config missing (or disabled), InfluxDB output disabled!")
@@ -452,7 +452,7 @@ func (u *InfluxUnifi) switchExport(r report, v any) { //nolint:cyclop
case *unifi.Event:
u.batchEvent(r, v)
case *unifi.IDS:
u.batchIDS(r, v)
u.batchIDs(r, v)
case *unifi.Alarm:
u.batchAlarms(r, v)
case *unifi.Anomaly: