From f1e5377aef76a7bfd8097276af6f245a5eb1d053 Mon Sep 17 00:00:00 2001 From: Sebastian Schubert Date: Sun, 19 Apr 2026 09:25:02 +0200 Subject: [PATCH 1/2] fix(probe): use switch-id field for managed switch name on FortiOS 7.4+ FortiOS 7.4 replaced the 'name' field with 'switch-id' in the managed-switch/status API response. Without this fix, all switches had an empty switch_name label causing duplicate metric errors. Fixes: https://github.com/prometheus-community/fortigate_exporter/issues/392 Signed-off-by: Sebastian Schubert --- pkg/probe/managed_switch.go | 68 +++++++++------- pkg/probe/managed_switch_test.go | 136 ++++++++++++++++++++++++++++++- 2 files changed, 173 insertions(+), 31 deletions(-) diff --git a/pkg/probe/managed_switch.go b/pkg/probe/managed_switch.go index 0ba7e3a..927b264 100644 --- a/pkg/probe/managed_switch.go +++ b/pkg/probe/managed_switch.go @@ -22,7 +22,7 @@ import ( "github.com/prometheus-community/fortigate_exporter/pkg/fortigatehttpclient" ) -func probeManagedSwitch(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]prometheus.Metric, bool) { +func probeManagedSwitch(c fortigatehttpclient.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) { var ( managedSwitchInfo = prometheus.NewDesc( "fortigate_managed_switch_info", @@ -217,6 +217,7 @@ func probeManagedSwitch(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]p type Results struct { Name string `json:"name"` + SwitchID string `json:"switch-id"` VDOM string `json:"vdom"` Serial string `json:"serial"` OSVersion string `json:"os_version"` @@ -240,46 +241,53 @@ func probeManagedSwitch(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]p return nil, false } + // FortiOS 7.4+ uses "switch-id" field; older versions use "name" + usesSwitchID := meta.VersionMajor > 7 || (meta.VersionMajor == 7 && meta.VersionMinor >= 4) + var m []prometheus.Metric for _, rs := range response { for _, result := range rs.Results { - m = append(m, prometheus.MustNewConstMetric(managedSwitchInfo, prometheus.CounterValue, 1, result.VDOM, result.Name, result.OSVersion, result.Serial, result.State, result.Status)) - m = append(m, prometheus.MustNewConstMetric(managedSwitchMaxPoeBudget, prometheus.CounterValue, result.MaxPoeBudget, result.VDOM, result.Name)) + switchName := result.Name + if usesSwitchID { + switchName = result.SwitchID + } + m = append(m, prometheus.MustNewConstMetric(managedSwitchInfo, prometheus.CounterValue, 1, result.VDOM, switchName, result.OSVersion, result.Serial, result.State, result.Status)) + m = append(m, prometheus.MustNewConstMetric(managedSwitchMaxPoeBudget, prometheus.CounterValue, result.MaxPoeBudget, result.VDOM, switchName)) for _, port := range result.Ports { if port.Status == "up" { - m = append(m, prometheus.MustNewConstMetric(portStatus, prometheus.GaugeValue, 1, result.VDOM, result.Name, port.Interface)) + m = append(m, prometheus.MustNewConstMetric(portStatus, prometheus.GaugeValue, 1, result.VDOM, switchName, port.Interface)) } else { - m = append(m, prometheus.MustNewConstMetric(portStatus, prometheus.GaugeValue, 0, result.VDOM, result.Name, port.Interface)) + m = append(m, prometheus.MustNewConstMetric(portStatus, prometheus.GaugeValue, 0, result.VDOM, switchName, port.Interface)) } - m = append(m, prometheus.MustNewConstMetric(portInfo, prometheus.GaugeValue, 1, result.VDOM, result.Name, port.Interface, port.Vlan, port.Duplex, port.Status, port.PoeStatus, strconv.FormatBool(port.PoeCapable))) - m = append(m, prometheus.MustNewConstMetric(portPower, prometheus.GaugeValue, port.PortPower, result.VDOM, result.Name, port.Interface)) - m = append(m, prometheus.MustNewConstMetric(portPowerStatus, prometheus.GaugeValue, port.PowerStatus, result.VDOM, result.Name, port.Interface)) + m = append(m, prometheus.MustNewConstMetric(portInfo, prometheus.GaugeValue, 1, result.VDOM, switchName, port.Interface, port.Vlan, port.Duplex, port.Status, port.PoeStatus, strconv.FormatBool(port.PoeCapable))) + m = append(m, prometheus.MustNewConstMetric(portPower, prometheus.GaugeValue, port.PortPower, result.VDOM, switchName, port.Interface)) + m = append(m, prometheus.MustNewConstMetric(portPowerStatus, prometheus.GaugeValue, port.PowerStatus, result.VDOM, switchName, port.Interface)) } for portName, port := range result.PortStats { - m = append(m, prometheus.MustNewConstMetric(portRxBytes, prometheus.CounterValue, port.BytesRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxBytes, prometheus.CounterValue, port.BytesTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxPackets, prometheus.CounterValue, port.PacketsRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxPackets, prometheus.CounterValue, port.PacketsTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxUcast, prometheus.CounterValue, port.UcastRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxUcast, prometheus.CounterValue, port.UcastTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxMcast, prometheus.CounterValue, port.McastRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxMcast, prometheus.CounterValue, port.McastTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxBcast, prometheus.CounterValue, port.BcastRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxBcast, prometheus.CounterValue, port.BcastTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxErrors, prometheus.CounterValue, port.ErrorsRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxErrors, prometheus.CounterValue, port.ErrorsTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxDrops, prometheus.CounterValue, port.DroppedRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxDrops, prometheus.CounterValue, port.DroppedTx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portRxOversize, prometheus.CounterValue, port.OversizeRx, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portTxOversize, prometheus.CounterValue, port.OversizeTx, result.VDOM, result.Name, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxBytes, prometheus.CounterValue, port.BytesRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxBytes, prometheus.CounterValue, port.BytesTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxPackets, prometheus.CounterValue, port.PacketsRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxPackets, prometheus.CounterValue, port.PacketsTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxUcast, prometheus.CounterValue, port.UcastRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxUcast, prometheus.CounterValue, port.UcastTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxMcast, prometheus.CounterValue, port.McastRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxMcast, prometheus.CounterValue, port.McastTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxBcast, prometheus.CounterValue, port.BcastRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxBcast, prometheus.CounterValue, port.BcastTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxErrors, prometheus.CounterValue, port.ErrorsRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxErrors, prometheus.CounterValue, port.ErrorsTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxDrops, prometheus.CounterValue, port.DroppedRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxDrops, prometheus.CounterValue, port.DroppedTx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portRxOversize, prometheus.CounterValue, port.OversizeRx, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portTxOversize, prometheus.CounterValue, port.OversizeTx, result.VDOM, switchName, portName)) - m = append(m, prometheus.MustNewConstMetric(portUndersize, prometheus.CounterValue, port.Undersize, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portFragments, prometheus.CounterValue, port.Fragments, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portJabbers, prometheus.CounterValue, port.Jabbers, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portCollisions, prometheus.CounterValue, port.Collisions, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portCrcAlignments, prometheus.CounterValue, port.CrcAlignments, result.VDOM, result.Name, portName)) - m = append(m, prometheus.MustNewConstMetric(portL3Packets, prometheus.CounterValue, port.L3Packets, result.VDOM, result.Name, portName)) + m = append(m, prometheus.MustNewConstMetric(portUndersize, prometheus.CounterValue, port.Undersize, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portFragments, prometheus.CounterValue, port.Fragments, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portJabbers, prometheus.CounterValue, port.Jabbers, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portCollisions, prometheus.CounterValue, port.Collisions, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portCrcAlignments, prometheus.CounterValue, port.CrcAlignments, result.VDOM, switchName, portName)) + m = append(m, prometheus.MustNewConstMetric(portL3Packets, prometheus.CounterValue, port.L3Packets, result.VDOM, switchName, portName)) } } } diff --git a/pkg/probe/managed_switch_test.go b/pkg/probe/managed_switch_test.go index abbf1f8..9b6cc62 100644 --- a/pkg/probe/managed_switch_test.go +++ b/pkg/probe/managed_switch_test.go @@ -24,8 +24,12 @@ import ( func TestProbeManagedSwitch(t *testing.T) { c := newFakeClient() c.prepare("api/v2/monitor/switch-controller/managed-switch/status", "testdata/managed-switch.jsonnet") + meta := &TargetMetadata{ + VersionMajor: 6, + VersionMinor: 4, + } r := prometheus.NewPedanticRegistry() - if !testProbe(probeManagedSwitch, c, r) { + if !testProbeWithMetadata(probeManagedSwitch, c, meta, r) { t.Errorf("probeManagedSwitchStatus() returned non-success") } @@ -844,3 +848,133 @@ func TestProbeManagedSwitch(t *testing.T) { t.Fatalf("metric compare: err %v", err) } } + +func TestProbeManagedSwitchFortiOS74(t *testing.T) { + c := newFakeClient() + c.prepare("api/v2/monitor/switch-controller/managed-switch/status", "testdata/managed-switch-74.jsonnet") + meta := &TargetMetadata{ + VersionMajor: 7, + VersionMinor: 4, + } + r := prometheus.NewPedanticRegistry() + if !testProbeWithMetadata(probeManagedSwitch, c, meta, r) { + t.Errorf("probeManagedSwitch() returned non-success") + } + + em := ` + # HELP fortigate_managed_switch_collisions_total Total number of collisions + # TYPE fortigate_managed_switch_collisions_total counter + fortigate_managed_switch_collisions_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_collisions_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_crc_alignments_total Total number of crc alignments + # TYPE fortigate_managed_switch_crc_alignments_total counter + fortigate_managed_switch_crc_alignments_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_crc_alignments_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_fragments_total Total number of fragments + # TYPE fortigate_managed_switch_fragments_total counter + fortigate_managed_switch_fragments_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_fragments_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_info Infos about a managed switch + # TYPE fortigate_managed_switch_info counter + fortigate_managed_switch_info{os_version="S124EF-v7.4.11-build2878 (GA)",serial="S124EF5920010261",state="Authorized",status="Connected",switch_name="FOO-SW-74",vdom="root"} 1 + # HELP fortigate_managed_switch_jabbers_total Total number of jabbers + # TYPE fortigate_managed_switch_jabbers_total counter + fortigate_managed_switch_jabbers_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_jabbers_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_l3_packets_total Total number of l3 packets + # TYPE fortigate_managed_switch_l3_packets_total counter + fortigate_managed_switch_l3_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_l3_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_max_poe_budget_watt Max poe budget watt + # TYPE fortigate_managed_switch_max_poe_budget_watt counter + fortigate_managed_switch_max_poe_budget_watt{switch_name="FOO-SW-74",vdom="root"} 370 + # HELP fortigate_managed_switch_port_info Infos about a switch port + # TYPE fortigate_managed_switch_port_info gauge + fortigate_managed_switch_port_info{duplex="",poe_capable="false",poe_status="",port="port2",status="down",switch_name="FOO-SW-74",vdom="root",vlan="VLAN-101"} 1 + fortigate_managed_switch_port_info{duplex="full",poe_capable="true",poe_status="enabled",port="port1",status="up",switch_name="FOO-SW-74",vdom="root",vlan="VLAN-4001"} 1 + # HELP fortigate_managed_switch_port_power_status Port power status + # TYPE fortigate_managed_switch_port_power_status gauge + fortigate_managed_switch_port_power_status{port="port1",switch_name="FOO-SW-74",vdom="root"} 2 + fortigate_managed_switch_port_power_status{port="port2",switch_name="FOO-SW-74",vdom="root"} 1 + # HELP fortigate_managed_switch_port_power_watt Port power in watt + # TYPE fortigate_managed_switch_port_power_watt gauge + fortigate_managed_switch_port_power_watt{port="port1",switch_name="FOO-SW-74",vdom="root"} 6 + fortigate_managed_switch_port_power_watt{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_port_status Port status up=1 down=0 + # TYPE fortigate_managed_switch_port_status gauge + fortigate_managed_switch_port_status{port="port1",switch_name="FOO-SW-74",vdom="root"} 1 + fortigate_managed_switch_port_status{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_bcast_packets_total Total number of received broadcast packets + # TYPE fortigate_managed_switch_rx_bcast_packets_total counter + fortigate_managed_switch_rx_bcast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 1 + fortigate_managed_switch_rx_bcast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_bytes_total Total number of received bytes + # TYPE fortigate_managed_switch_rx_bytes_total counter + fortigate_managed_switch_rx_bytes_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 2000 + fortigate_managed_switch_rx_bytes_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_drops_total Total number of received drops + # TYPE fortigate_managed_switch_rx_drops_total counter + fortigate_managed_switch_rx_drops_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_rx_drops_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_errors_total Total number of received errors + # TYPE fortigate_managed_switch_rx_errors_total counter + fortigate_managed_switch_rx_errors_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_rx_errors_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_mcast_packets_total Total number of received multicast packets + # TYPE fortigate_managed_switch_rx_mcast_packets_total counter + fortigate_managed_switch_rx_mcast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 1 + fortigate_managed_switch_rx_mcast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_oversize_total Total number of received oversize + # TYPE fortigate_managed_switch_rx_oversize_total counter + fortigate_managed_switch_rx_oversize_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_rx_oversize_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_packets_total Total number of received packets + # TYPE fortigate_managed_switch_rx_packets_total counter + fortigate_managed_switch_rx_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 20 + fortigate_managed_switch_rx_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_rx_ucast_packets_total Total number of received unicast packets + # TYPE fortigate_managed_switch_rx_ucast_packets_total counter + fortigate_managed_switch_rx_ucast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 18 + fortigate_managed_switch_rx_ucast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_bcast_packets_total Total number of transmitted broadcast packets + # TYPE fortigate_managed_switch_tx_bcast_packets_total counter + fortigate_managed_switch_tx_bcast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 1 + fortigate_managed_switch_tx_bcast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_bytes_total Total number of transmitted bytes + # TYPE fortigate_managed_switch_tx_bytes_total counter + fortigate_managed_switch_tx_bytes_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 1000 + fortigate_managed_switch_tx_bytes_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_drops_total Total number of transmitted drops + # TYPE fortigate_managed_switch_tx_drops_total counter + fortigate_managed_switch_tx_drops_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_tx_drops_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_errors_total Total number of transmitted errors + # TYPE fortigate_managed_switch_tx_errors_total counter + fortigate_managed_switch_tx_errors_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_tx_errors_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_mcast_packets_total Total number of transmitted multicast packets + # TYPE fortigate_managed_switch_tx_mcast_packets_total counter + fortigate_managed_switch_tx_mcast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 1 + fortigate_managed_switch_tx_mcast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_oversize_total Total number of transmitted oversize + # TYPE fortigate_managed_switch_tx_oversize_total counter + fortigate_managed_switch_tx_oversize_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_tx_oversize_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_packets_total Total number of transmitted packets + # TYPE fortigate_managed_switch_tx_packets_total counter + fortigate_managed_switch_tx_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 10 + fortigate_managed_switch_tx_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_tx_ucast_packets_total Total number of transmitted unicast packets + # TYPE fortigate_managed_switch_tx_ucast_packets_total counter + fortigate_managed_switch_tx_ucast_packets_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 8 + fortigate_managed_switch_tx_ucast_packets_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + # HELP fortigate_managed_switch_under_size_total Total number of under size + # TYPE fortigate_managed_switch_under_size_total counter + fortigate_managed_switch_under_size_total{port="port1",switch_name="FOO-SW-74",vdom="root"} 0 + fortigate_managed_switch_under_size_total{port="port2",switch_name="FOO-SW-74",vdom="root"} 0 + ` + + if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil { + t.Fatalf("metric compare: err %v", err) + } +} From 1215eefe2d4bb458ffca311fd7dfaede31ddc2c5 Mon Sep 17 00:00:00 2001 From: Sebastian Schubert Date: Sun, 19 Apr 2026 23:42:22 +0200 Subject: [PATCH 2/2] added missiong testdata Signed-off-by: Sebastian Schubert --- pkg/probe/testdata/managed-switch-74.jsonnet | 119 +++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 pkg/probe/testdata/managed-switch-74.jsonnet diff --git a/pkg/probe/testdata/managed-switch-74.jsonnet b/pkg/probe/testdata/managed-switch-74.jsonnet new file mode 100644 index 0000000..76b0fa4 --- /dev/null +++ b/pkg/probe/testdata/managed-switch-74.jsonnet @@ -0,0 +1,119 @@ +# api/v2/monitor/switch-controller/managed-switch/status?vdom=* +[ + { + "http_method":"GET", + "results":[ + { + "switch-id":"FOO-SW-74", + "serial":"S124EF5920010261", + "fgt_peer_intf_name":"fortilink", + "state":"Authorized", + "status":"Connected", + "os_version":"S124EF-v7.4.11-build2878 (GA)", + "connecting_from":"10.249.5.132", + "join_time":"Mon Jan 1 00:00:00 2024\n", + "type":"physical", + "ports":[ + { + "interface":"port1", + "status":"up", + "duplex":"full", + "speed":1000, + "port_power":6, + "power_status":2, + "fortilink_port":false, + "vlan":"VLAN-4001", + "fgt_peer_port_name":"", + "fgt_peer_device_name":"", + "isl_peer_device_name":"", + "isl_peer_port_name":"", + "isl_peer_trunk_name":"", + "mclag_icl":false, + "poe_capable":true, + "poe_status":"enabled", + "supported_port_speeds":[] + }, + { + "interface":"port2", + "status":"down", + "port_power":0, + "power_status":1, + "fortilink_port":false, + "vlan":"VLAN-101", + "fgt_peer_port_name":"", + "fgt_peer_device_name":"", + "isl_peer_device_name":"", + "isl_peer_port_name":"", + "isl_peer_trunk_name":"", + "mclag_icl":false, + "poe_capable":false, + "supported_port_speeds":[] + } + ], + "max_poe_budget":370, + "igmp_snooping_supported":true, + "dhcp_snooping_supported":true, + "mc_lag_supported":false, + "led_blink_supported":true, + "port_stats":{ + "port1":{ + "tx-bytes":1000, + "tx-packets":10, + "tx-ucast":8, + "tx-mcast":1, + "tx-bcast":1, + "tx-errors":0, + "tx-drops":0, + "tx-oversize":0, + "rx-bytes":2000, + "rx-packets":20, + "rx-ucast":18, + "rx-mcast":1, + "rx-bcast":1, + "rx-errors":0, + "rx-drops":0, + "rx-oversize":0, + "undersize":0, + "fragments":0, + "jabbers":0, + "collisions":0, + "crc-alignments":0, + "l3packets":0 + }, + "port2":{ + "tx-bytes":0, + "tx-packets":0, + "tx-ucast":0, + "tx-mcast":0, + "tx-bcast":0, + "tx-errors":0, + "tx-drops":0, + "tx-oversize":0, + "rx-bytes":0, + "rx-packets":0, + "rx-ucast":0, + "rx-mcast":0, + "rx-bcast":0, + "rx-errors":0, + "rx-drops":0, + "rx-oversize":0, + "undersize":0, + "fragments":0, + "jabbers":0, + "collisions":0, + "crc-alignments":0, + "l3packets":0 + } + }, + "vdom":"root" + } + ], + "vdom":"root", + "path":"switch-controller", + "name":"managed-switch", + "status":"success", + "serial":"FGT600F0000XXXX", + "version":"v7.4.11", + "build":2878 + } +]