Skip to content

Commit 58768f5

Browse files
committed
Test fixes
Signed-off-by: jiri <jiri@chainlayer.io>
1 parent d1fbc91 commit 58768f5

3 files changed

Lines changed: 463 additions & 420 deletions

File tree

pkg/probe/fortiswitch_port_stats.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package probe
33
import (
44
"log"
55
"fmt"
6-
76
"github.com/bluecmd/fortigate_exporter/pkg/http"
87
"github.com/prometheus/client_golang/prometheus"
98
)
@@ -12,7 +11,9 @@ func probeSwitchPortStats(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
1211
var (
1312
mSwitchStatus = prometheus.NewDesc(
1413
"fortiswitch_status",
15-
"Whether the switch is connected or not. \n # fgt_peer_intf_name = FortiLink interface that the FortiSwitch is connected to # \n connection_from = FortiSwitch port that is connected to the FortiLink interface",
14+
`Whether the switch is connected or not
15+
# fgt_peer_intf_name = FortiLink interface that the FortiSwitch is connected to
16+
# connection_from = FortiSwitch port that is connected to the FortiLink interface`,
1617
[]string{"vdom", "name", "serial_number", "fgt_peer_intf_name", "connection_from", "state"}, nil,
1718
)
1819
mPortStatus = prometheus.NewDesc(
@@ -234,14 +235,14 @@ func probeSwitchPortStats(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
234235

235236
var swState float64
236237
if swr.State == "Authorized" {
237-
swState = 1
238+
swState = 1.0
238239
} else if swr.State == "DeAuthorized" {
239-
swState = 0
240+
swState = 0.0
240241
} else if swr.State == "Discovered" {
241-
swState = 2
242+
swState = 2.0
242243
}
243244

244-
m = append(m, prometheus.MustNewConstMetric(mSwitchStatus, prometheus.GaugeValue, swStatus, swr.Vdom, swr.Name, swr.Serial, swr.FgPeerIntfName, swr.Connecting_from, fmt.Sprintf("%f", swState)))
245+
m = append(m, prometheus.MustNewConstMetric(mSwitchStatus, prometheus.GaugeValue, swStatus, swr.Vdom, swr.Name, swr.Serial, swr.FgPeerIntfName, swr.Connecting_from, fmt.Sprintf("%0.f", swState)))
245246

246247
for _, pi := range swr.Ports {
247248
pStatus := 0.0

0 commit comments

Comments
 (0)