Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit bb36292

Browse files
committed
Fix lint
1 parent 314357e commit bb36292

File tree

4 files changed

+54
-28
lines changed

4 files changed

+54
-28
lines changed

collector/collector.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import (
77
"errors"
88
"fmt"
99
"io"
10+
"mikrotik-exporter/config"
1011
"net"
1112
"os"
1213
"strconv"
1314
"strings"
1415
"sync"
1516
"time"
1617

17-
"mikrotik-exporter/config"
18-
1918
"github.com/miekg/dns"
2019
"github.com/prometheus/client_golang/prometheus"
2120
log "github.com/sirupsen/logrus"
@@ -263,7 +262,6 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
263262
dnsMsg.RecursionDesired = true
264263
dnsMsg.SetQuestion(dns.Fqdn(dev.Srv.Record), dns.TypeSRV)
265264
r, _, err := dnsCli.Exchange(dnsMsg, dnsServer)
266-
267265
if err != nil {
268266
os.Exit(1)
269267
}
@@ -415,11 +413,13 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
415413
// Login method pre-6.43 two stages, challenge
416414
b, err := hex.DecodeString(ret)
417415
if err != nil {
418-
return nil, fmt.Errorf("RouterOS: /login: invalid ret (challenge) hex string received: %s", err)
416+
return nil, fmt.Errorf(
417+
"RouterOS: /login: invalid ret (challenge) hex string received: %s",
418+
err,
419+
)
419420
}
420421

421-
r, err = client.Run("/login", "=name="+d.User, "=response="+challengeResponse(b, d.Password))
422-
if err != nil {
422+
if _, err = client.Run("/login", "=name="+d.User, "=response="+challengeResponse(b, d.Password)); err != nil {
423423
return nil, err
424424
}
425425
log.WithField("device", d.Name).Debug("done wth login")

collector/firmware_collector.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
)
99

1010
type firmwareCollector struct {
11-
props []string
1211
description *prometheus.Desc
1312
}
1413

collector/poe_collector.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ func (c *poeCollector) collect(ctx *collectorContext) error {
5757
return c.collectPOEMetricsForInterfaces(ifaces, ctx)
5858
}
5959

60-
func (c *poeCollector) collectPOEMetricsForInterfaces(ifaces []string, ctx *collectorContext) error {
60+
func (c *poeCollector) collectPOEMetricsForInterfaces(
61+
ifaces []string,
62+
ctx *collectorContext,
63+
) error {
6164
reply, err := ctx.client.Run("/interface/ethernet/poe/monitor",
6265
"=numbers="+strings.Join(ifaces, ","),
6366
"=once=",
@@ -82,7 +85,11 @@ func (c *poeCollector) collectPOEMetricsForInterfaces(ifaces []string, ctx *coll
8285
return nil
8386
}
8487

85-
func (c *poeCollector) collectMetricsForInterface(name string, se *proto.Sentence, ctx *collectorContext) {
88+
func (c *poeCollector) collectMetricsForInterface(
89+
name string,
90+
se *proto.Sentence,
91+
ctx *collectorContext,
92+
) {
8693
for _, prop := range c.props {
8794
v, ok := se.Map[prop]
8895
if !ok {
@@ -106,10 +113,6 @@ func (c *poeCollector) collectMetricsForInterface(name string, se *proto.Sentenc
106113
}
107114
}
108115

109-
func (c *poeCollector) valueForKey(name, value string) (float64, error) {
110-
return strconv.ParseFloat(value, 64)
111-
}
112-
113116
func (c *poeCollector) descForKey(name string) *prometheus.Desc {
114117
switch name {
115118
case "poe-out-current":

collector/w60g_collector.go

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (c *w60gInterfaceCollector) describe(ch chan<- *prometheus.Desc) {
3131
ch <- c.txDistanceDesc
3232
ch <- c.txPacketErrorRateDesc
3333
}
34+
3435
func (c *w60gInterfaceCollector) collect(ctx *collectorContext) error {
3536
reply, err := ctx.client.Run("/interface/w60g/print", "=.proplist=name")
3637
if err != nil {
@@ -53,7 +54,11 @@ func (c *w60gInterfaceCollector) collect(ctx *collectorContext) error {
5354

5455
return c.collectw60gMetricsForInterfaces(ifaces, ctx)
5556
}
56-
func (c *w60gInterfaceCollector) collectw60gMetricsForInterfaces(ifaces []string, ctx *collectorContext) error {
57+
58+
func (c *w60gInterfaceCollector) collectw60gMetricsForInterfaces(
59+
ifaces []string,
60+
ctx *collectorContext,
61+
) error {
5762
reply, err := ctx.client.Run("/interface/w60g/monitor",
5863
"=numbers="+strings.Join(ifaces, ","),
5964
"=once=",
@@ -77,7 +82,11 @@ func (c *w60gInterfaceCollector) collectw60gMetricsForInterfaces(ifaces []string
7782
return nil
7883
}
7984

80-
func (c *w60gInterfaceCollector) collectMetricsForw60gInterface(name string, se *proto.Sentence, ctx *collectorContext) {
85+
func (c *w60gInterfaceCollector) collectMetricsForw60gInterface(
86+
name string,
87+
se *proto.Sentence,
88+
ctx *collectorContext,
89+
) {
8190
for _, prop := range c.props {
8291
v, ok := se.Map[prop]
8392
if !ok {
@@ -106,22 +115,37 @@ func neww60gInterfaceCollector() routerOSCollector {
106115

107116
labelNames := []string{"name", "address", "interface"}
108117
return &w60gInterfaceCollector{
109-
frequencyDesc: description(prefix, "frequency", "frequency of tx in MHz", labelNames),
110-
txMCSDesc: description(prefix, "txMCS", "TX MCS", labelNames),
111-
txPHYRateDesc: description(prefix, "txPHYRate", "PHY Rate in bps", labelNames),
112-
signalDesc: description(prefix, "signal", "Signal quality in %", labelNames),
113-
rssiDesc: description(prefix, "rssi", "Signal RSSI in dB", labelNames),
114-
txSectorDesc: description(prefix, "txSector", "TX Sector", labelNames),
115-
txDistanceDesc: description(prefix, "txDistance", "Distance to remote", labelNames),
116-
txPacketErrorRateDesc: description(prefix, "txPacketErrorRate", "TX Packet Error Rate", labelNames),
117-
props: []string{"signal", "rssi", "tx-mcs", "frequency", "tx-phy-rate", "tx-sector", "distance", "tx-packet-error-rate"},
118+
frequencyDesc: description(
119+
prefix,
120+
"frequency",
121+
"frequency of tx in MHz",
122+
labelNames,
123+
),
124+
txMCSDesc: description(prefix, "txMCS", "TX MCS", labelNames),
125+
txPHYRateDesc: description(prefix, "txPHYRate", "PHY Rate in bps", labelNames),
126+
signalDesc: description(prefix, "signal", "Signal quality in %", labelNames),
127+
rssiDesc: description(prefix, "rssi", "Signal RSSI in dB", labelNames),
128+
txSectorDesc: description(prefix, "txSector", "TX Sector", labelNames),
129+
txDistanceDesc: description(prefix, "txDistance", "Distance to remote", labelNames),
130+
txPacketErrorRateDesc: description(
131+
prefix,
132+
"txPacketErrorRate",
133+
"TX Packet Error Rate",
134+
labelNames,
135+
),
136+
props: []string{
137+
"signal",
138+
"rssi",
139+
"tx-mcs",
140+
"frequency",
141+
"tx-phy-rate",
142+
"tx-sector",
143+
"distance",
144+
"tx-packet-error-rate",
145+
},
118146
}
119147
}
120148

121-
func (c *w60gInterfaceCollector) valueForKey(name, value string) (float64, error) {
122-
return strconv.ParseFloat(value, 64)
123-
}
124-
125149
func (c *w60gInterfaceCollector) descForKey(name string) *prometheus.Desc {
126150
switch name {
127151
case "signal":

0 commit comments

Comments
 (0)