Skip to content

Commit e48d3e4

Browse files
committed
Linter installed and run with --fix
1 parent 968d0c9 commit e48d3e4

File tree

3 files changed

+43
-41
lines changed

3 files changed

+43
-41
lines changed

pkg/probe/network_dns_latency.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ package probe
1515

1616
import (
1717
"log"
18-
"github.com/prometheus-community/fortigate_exporter/pkg/http"
18+
1919
"github.com/prometheus/client_golang/prometheus"
20+
21+
"github.com/prometheus-community/fortigate_exporter/pkg/http"
2022
)
2123

2224
func probeNetworkDNSLatency(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric, bool) {
23-
var (
24-
dnsLatency = prometheus.NewDesc(
25-
"fortigate_network_dns_latency_seconds",
26-
"Network dns latency",
27-
[]string{"service", "ip"}, nil,
28-
)
25+
dnsLatency := prometheus.NewDesc(
26+
"fortigate_network_dns_latency_seconds",
27+
"Network dns latency",
28+
[]string{"service", "ip"}, nil,
2929
)
3030

3131
type DNSLatencty struct {
@@ -46,8 +46,8 @@ func probeNetworkDNSLatency(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.M
4646
}
4747
m := []prometheus.Metric{}
4848
for _, r := range res.Results {
49-
m = append(m, prometheus.MustNewConstMetric(dnsLatency, prometheus.GaugeValue, r.Latency * 0.001, r.Service, r.IP))
49+
m = append(m, prometheus.MustNewConstMetric(dnsLatency, prometheus.GaugeValue, r.Latency*0.001, r.Service, r.IP))
5050
}
5151

5252
return m, true
53-
}
53+
}

pkg/probe/network_dns_latency_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package probe
1515
import (
1616
"strings"
1717
"testing"
18+
1819
"github.com/prometheus/client_golang/prometheus"
1920
"github.com/prometheus/client_golang/prometheus/testutil"
2021
)
@@ -36,4 +37,4 @@ func TestNetworkDnsLatency(t *testing.T) {
3637
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
3738
t.Fatalf("metric compare: err %v", err)
3839
}
39-
}
40+
}

pkg/probe/system_vdom-resource.go

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ package probe
1515

1616
import (
1717
"log"
18-
"github.com/prometheus-community/fortigate_exporter/pkg/http"
18+
1919
"github.com/prometheus/client_golang/prometheus"
20+
21+
"github.com/prometheus-community/fortigate_exporter/pkg/http"
2022
)
2123

22-
func probeSystemVdomResource(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
23-
24+
func probeSystemVdomResource(c http.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric, bool) {
2425
vdomDesc := make(map[string]*prometheus.Desc)
2526
vdomDesc["cpu"] = prometheus.NewDesc(
2627
"fortigate_vdom_resource_cpu_usage_ratio",
@@ -45,12 +46,12 @@ func probeSystemVdomResource(c http.FortiHTTP, meta *TargetMetadata) ([]promethe
4546
vdomDesc["id"] = prometheus.NewDesc(
4647
"fortigate_vdom_resource_object_id",
4748
"Object Resource ID",
48-
[]string{"vdom", "object"},nil,
49+
[]string{"vdom", "object"}, nil,
4950
)
5051
vdomDesc["custom_max"] = prometheus.NewDesc(
5152
"fortigate_vdom_resource_object_custom_max",
5253
"Object Custom Max",
53-
[]string{"vdom", "object"},nil,
54+
[]string{"vdom", "object"}, nil,
5455
)
5556
vdomDesc["min_custom_value"] = prometheus.NewDesc(
5657
"fortigate_vdom_resource_object_custom_min_value",
@@ -60,42 +61,42 @@ func probeSystemVdomResource(c http.FortiHTTP, meta *TargetMetadata) ([]promethe
6061
vdomDesc["max_custom_value"] = prometheus.NewDesc(
6162
"fortigate_vdom_resource_object_custom_max_value",
6263
"Object Maximum custom value",
63-
[]string{"vdom", "object"},nil,
64+
[]string{"vdom", "object"}, nil,
6465
)
6566
vdomDesc["guaranteed"] = prometheus.NewDesc(
6667
"fortigate_vdom_resource_object_guaranteed",
6768
"Object Guaranteed",
68-
[]string{"vdom", "object"},nil,
69+
[]string{"vdom", "object"}, nil,
6970
)
7071
vdomDesc["min_guaranteed_value"] = prometheus.NewDesc(
7172
"fortigate_vdom_resource_object_guaranteed_max_value",
7273
"Object Minimum guaranteed value",
73-
[]string{"vdom", "object"},nil,
74+
[]string{"vdom", "object"}, nil,
7475
)
7576
vdomDesc["max_guaranteed_value"] = prometheus.NewDesc(
7677
"fortigate_vdom_resource_object_guaranteed_min_value",
7778
"Object Maximum guaranteed value",
78-
[]string{"vdom", "object"},nil,
79+
[]string{"vdom", "object"}, nil,
7980
)
8081
vdomDesc["global_max"] = prometheus.NewDesc(
8182
"fortigate_vdom_resource_object_global_max",
8283
"Object Global max",
83-
[]string{"vdom", "object"},nil,
84+
[]string{"vdom", "object"}, nil,
8485
)
8586
vdomDesc["current_usage"] = prometheus.NewDesc(
8687
"fortigate_vdom_resource_object_current_usage",
8788
"Object Current usage",
88-
[]string{"vdom", "object"},nil,
89+
[]string{"vdom", "object"}, nil,
8990
)
9091
vdomDesc["usage_percent"] = prometheus.NewDesc(
9192
"fortigate_vdom_resource_object_usage_ratio",
9293
"Object Usage percentage",
93-
[]string{"vdom", "object"},nil,
94+
[]string{"vdom", "object"}, nil,
9495
)
9596

9697
type VDOMResourceResult struct {
97-
Result interface{} `json:"results"`
98-
Vdom string `json:"vdom"`
98+
Result any `json:"results"`
99+
Vdom string `json:"vdom"`
99100
}
100101

101102
var res []VDOMResourceResult
@@ -117,23 +118,23 @@ func probeSystemVdomResource(c http.FortiHTTP, meta *TargetMetadata) ([]promethe
117118
m = append(m, prometheus.MustNewConstMetric(vdomDesc[k], prometheus.GaugeValue, 0, result.Vdom))
118119
}
119120
case "session",
120-
"ipsec-phase1",
121-
"ipsec-phase2",
122-
"ipsec-phase1-interface",
123-
"ipsec-phase2-interface",
124-
"dialup-tunnel",
125-
"firewall-policy",
126-
"firewall-address",
127-
"firewall-addrgrp",
128-
"custom-service",
129-
"service-group",
130-
"onetime-schedule",
131-
"recurring-schedule",
132-
"user",
133-
"user-group",
134-
"sslvpn",
135-
"proxy",
136-
"log-disk-quota":
121+
"ipsec-phase1",
122+
"ipsec-phase2",
123+
"ipsec-phase1-interface",
124+
"ipsec-phase2-interface",
125+
"dialup-tunnel",
126+
"firewall-policy",
127+
"firewall-address",
128+
"firewall-addrgrp",
129+
"custom-service",
130+
"service-group",
131+
"onetime-schedule",
132+
"recurring-schedule",
133+
"user",
134+
"user-group",
135+
"sslvpn",
136+
"proxy",
137+
"log-disk-quota":
137138
for val, e := range elem.(map[string]any) {
138139
m = append(m, prometheus.MustNewConstMetric(vdomDesc[val], prometheus.GaugeValue, e.(float64), result.Vdom, k))
139140
}

0 commit comments

Comments
 (0)