Skip to content

Commit 68fb0c8

Browse files
New version for 7.6 with state set instead of numbers (#366)
* New version for 7.6 with state set instead of numbers Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> * New stateset implemented Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> * Updated metric.md and corrected lint errors Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> * Renamed functions and testfiles to version number Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> * changed test functions as well Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> --------- Signed-off-by: Örnfeldt Philip (66140321) <philip.ornfeldt@forsakringskassan.se> Signed-off-by: Philip Örnfeldt <philip.ornfeldt@outlook.com> Co-authored-by: Sebastian Schubert <16682281+bastischubert@users.noreply.github.com>
1 parent 451376c commit 68fb0c8

File tree

7 files changed

+305
-19
lines changed

7 files changed

+305
-19
lines changed

metrics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ Per-VDOM:
182182
Per-BGP-Neighbor and VDOM:
183183
* _BGP/Neighbors/IPv4_
184184
* `fortigate_bgp_neighbor_ipv4_info`
185+
* `fortigate_bgp_neighbor_ipv4_state`
185186
* _BGP/Neighbors/IPv6_
186187
* `fortigate_bgp_neighbor_ipv6_info`
188+
* `fortigate_bgp_neighbor_ipv6_state`
187189
* _BGP/NeighborPaths/IPv4_
188190
* `fortigate_bgp_neighbor_ipv4_paths`
189191
* `fortigate_bgp_neighbor_ipv4_best_paths`

pkg/probe/bgp_neighbors.go

Lines changed: 125 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ import (
2222
"github.com/prometheus-community/fortigate_exporter/pkg/http"
2323
)
2424

25-
type BGPNeighbor struct {
25+
type BGPNeighbor7_4 struct {
2626
NeighborIP string `json:"neighbor_ip"`
2727
LocalIP string `json:"local_ip"`
2828
RemoteAS int `json:"remote_as"`
2929
AdminStatus bool `json:"admin_status"`
3030
State string `json:"state"`
3131
}
3232

33-
type BGPNeighborResponse struct {
34-
Results []BGPNeighbor `json:"results"`
35-
VDOM string `json:"vdom"`
36-
Version string `json:"version"`
33+
type BGPNeighborResponse7_4 struct {
34+
Results []BGPNeighbor7_4 `json:"results"`
35+
VDOM string `json:"vdom"`
36+
Version string `json:"version"`
3737
}
3838

39-
func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
39+
func probeBGPNeighborsIPv47_4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
4040
if meta.VersionMajor < 7 {
4141
// not supported version. Before 7.0.0 the requested endpoint doesn't exist
4242
return nil, true
@@ -47,7 +47,7 @@ func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus
4747
[]string{"vdom", "remote_as", "state", "admin_status", "local_ip", "neighbor_ip"}, nil,
4848
)
4949

50-
var rs []BGPNeighborResponse
50+
var rs []BGPNeighborResponse7_4
5151

5252
if err := c.Get("api/v2/monitor/router/bgp/neighbors", "vdom=*", &rs); err != nil {
5353
log.Printf("Error: %v", err)
@@ -65,7 +65,7 @@ func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus
6565
return m, true
6666
}
6767

68-
func probeBGPNeighborsIPv6(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
68+
func probeBGPNeighborsIPv67_4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
6969
if meta.VersionMajor < 7 {
7070
// not supported version. Before 7.0.0 the requested endpoint doesn't exist
7171
return nil, true
@@ -77,7 +77,7 @@ func probeBGPNeighborsIPv6(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus
7777
[]string{"vdom", "remote_as", "state", "admin_status", "local_ip", "neighbor_ip"}, nil,
7878
)
7979

80-
var rs []BGPNeighborResponse
80+
var rs []BGPNeighborResponse7_4
8181

8282
if err := c.Get("api/v2/monitor/router/bgp/neighbors6", "vdom=*", &rs); err != nil {
8383
log.Printf("Error: %v", err)
@@ -113,3 +113,119 @@ func bgpStateToNumber(bgpState string) float64 {
113113
return 0
114114
}
115115
}
116+
117+
type BGPNeighbor struct {
118+
NeighborIP string `json:"neighbor_ip"`
119+
LocalIP string `json:"local_ip"`
120+
RemoteAS string `json:"remote_as"`
121+
AdminStatus bool `json:"admin_status"`
122+
State string `json:"state"`
123+
}
124+
125+
type BGPNeighborResponse struct {
126+
Results []BGPNeighbor `json:"results"`
127+
VDOM string `json:"vdom"`
128+
Version string `json:"version"`
129+
}
130+
131+
func probeBGPNeighborsIPv4(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
132+
if meta.VersionMajor == 7 && meta.VersionMinor < 6 {
133+
return probeBGPNeighborsIPv47_4(c, meta)
134+
}
135+
136+
mBGPNeighborState := prometheus.NewDesc(
137+
"fortigate_bgp_neighbor_ipv4_state",
138+
"Configured bgp neighbor over ipv4 state",
139+
[]string{"vdom", "remote_as", "admin_status", "local_ip", "neighbor_ip", "state"}, nil,
140+
)
141+
142+
var rs []BGPNeighborResponse
143+
144+
if err := c.Get("api/v2/monitor/router/bgp/neighbors", "vdom=*", &rs); err != nil {
145+
log.Printf("Error: %v", err)
146+
return nil, false
147+
}
148+
149+
m := []prometheus.Metric{}
150+
151+
for _, r := range rs {
152+
for _, peer := range r.Results {
153+
t := []prometheus.Metric{
154+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Idle"),
155+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Connect"),
156+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Active"),
157+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Open sent"),
158+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Open confirm"),
159+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Established"),
160+
}
161+
switch peer.State {
162+
case "Idle":
163+
t[0] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
164+
case "Connect":
165+
t[1] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
166+
case "Active":
167+
t[2] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
168+
case "Open sent":
169+
t[3] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
170+
case "Open confirm":
171+
t[4] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
172+
case "Established":
173+
t[5] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
174+
}
175+
m = append(m, t...)
176+
}
177+
}
178+
179+
return m, true
180+
}
181+
182+
func probeBGPNeighborsIPv6(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Metric, bool) {
183+
if meta.VersionMajor == 7 && meta.VersionMinor < 6 {
184+
return probeBGPNeighborsIPv67_4(c, meta)
185+
}
186+
187+
mBGPNeighborState := prometheus.NewDesc(
188+
"fortigate_bgp_neighbor_ipv6_state",
189+
"Configured bgp neighbor over ipv6 state",
190+
[]string{"vdom", "remote_as", "admin_status", "local_ip", "neighbor_ip", "state"}, nil,
191+
)
192+
193+
var rs []BGPNeighborResponse
194+
195+
if err := c.Get("api/v2/monitor/router/bgp/neighbors6", "vdom=*", &rs); err != nil {
196+
log.Printf("Error: %v", err)
197+
return nil, false
198+
}
199+
200+
m := []prometheus.Metric{}
201+
202+
for _, r := range rs {
203+
for _, peer := range r.Results {
204+
t := []prometheus.Metric{
205+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Idle"),
206+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Connect"),
207+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Active"),
208+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Open sent"),
209+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Open confirm"),
210+
prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 0.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, "Established"),
211+
}
212+
switch peer.State {
213+
case "Idle":
214+
t[0] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
215+
case "Connect":
216+
t[1] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
217+
case "Active":
218+
t[2] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
219+
case "Open sent":
220+
t[3] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
221+
case "Open confirm":
222+
t[4] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
223+
case "Established":
224+
t[5] = prometheus.MustNewConstMetric(mBGPNeighborState, prometheus.GaugeValue, 1.0, r.VDOM, peer.RemoteAS, strconv.FormatBool(peer.AdminStatus), peer.LocalIP, peer.NeighborIP, peer.State)
225+
}
226+
m = append(m, t...)
227+
}
228+
}
229+
230+
return m, true
231+
}

pkg/probe/bgp_neighbors_test.go

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,85 @@ import (
2121
"github.com/prometheus/client_golang/prometheus/testutil"
2222
)
2323

24+
func TestBGPNeighborsIPv47_4(t *testing.T) {
25+
c := newFakeClient()
26+
c.prepare("api/v2/monitor/router/bgp/neighbors", "testdata/router-bgp-neighbors-v4-7.4.jsonnet")
27+
r := prometheus.NewPedanticRegistry()
28+
meta := &TargetMetadata{
29+
VersionMajor: 7,
30+
VersionMinor: 4,
31+
}
32+
if !testProbeWithMetadata(probeBGPNeighborsIPv4, c, meta, r) {
33+
t.Errorf("probeBGPNeighborsIPv4() returned non-success")
34+
}
35+
36+
em := `
37+
# HELP fortigate_bgp_neighbor_ipv4_info Configured bgp neighbor over ipv4, return state as value (1 - Idle, 2 - Connect, 3 - Active, 4 - Open sent, 5 - Open confirm, 6 - Established)
38+
# TYPE fortigate_bgp_neighbor_ipv4_info gauge
39+
fortigate_bgp_neighbor_ipv4_info{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Established",vdom="root"} 6
40+
`
41+
42+
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
43+
t.Fatalf("metric compare: err %v", err)
44+
}
45+
}
46+
47+
func TestBGPNeighborsIPv67_4(t *testing.T) {
48+
c := newFakeClient()
49+
c.prepare("api/v2/monitor/router/bgp/neighbors6", "testdata/router-bgp-neighbors-v6-7.4.jsonnet")
50+
r := prometheus.NewPedanticRegistry()
51+
meta := &TargetMetadata{
52+
VersionMajor: 7,
53+
VersionMinor: 4,
54+
}
55+
if !testProbeWithMetadata(probeBGPNeighborsIPv6, c, meta, r) {
56+
t.Errorf("probeBGPNeighborsIPv6() returned non-success")
57+
}
58+
59+
em := `
60+
# HELP fortigate_bgp_neighbor_ipv6_info Configured bgp neighbor over ipv6, return state as value (1 - Idle, 2 - Connect, 3 - Active, 4 - Open sent, 5 - Open confirm, 6 - Established)
61+
# TYPE fortigate_bgp_neighbor_ipv6_info gauge
62+
fortigate_bgp_neighbor_ipv6_info{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Established",vdom="root"} 6
63+
`
64+
65+
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
66+
t.Fatalf("metric compare: err %v", err)
67+
}
68+
}
69+
2470
func TestBGPNeighborsIPv4(t *testing.T) {
2571
c := newFakeClient()
2672
c.prepare("api/v2/monitor/router/bgp/neighbors", "testdata/router-bgp-neighbors-v4.jsonnet")
2773
r := prometheus.NewPedanticRegistry()
28-
if !testProbe(probeBGPNeighborsIPv4, c, r) {
74+
meta := &TargetMetadata{
75+
VersionMajor: 7,
76+
VersionMinor: 6,
77+
}
78+
if !testProbeWithMetadata(probeBGPNeighborsIPv4, c, meta, r) {
2979
t.Errorf("probeBGPNeighborsIPv4() returned non-success")
3080
}
3181

3282
em := `
33-
# HELP fortigate_bgp_neighbor_ipv4_info Configured bgp neighbor over ipv4, return state as value (1 - Idle, 2 - Connect, 3 - Active, 4 - Open sent, 5 - Open confirm, 6 - Established)
34-
# TYPE fortigate_bgp_neighbor_ipv4_info gauge
35-
fortigate_bgp_neighbor_ipv4_info{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Established",vdom="root"} 6
83+
# HELP fortigate_bgp_neighbor_ipv4_state Configured bgp neighbor over ipv4 state
84+
# TYPE fortigate_bgp_neighbor_ipv4_state gauge
85+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Active",vdom="root"} 0
86+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Connect",vdom="root"} 0
87+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Established",vdom="root"} 1
88+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Idle",vdom="root"} 0
89+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Open confirm",vdom="root"} 0
90+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="10.0.0.0",neighbor_ip="10.0.0.1",remote_as="1337",state="Open sent",vdom="root"} 0
91+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Active",vdom="root"} 1
92+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Connect",vdom="root"} 0
93+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Established",vdom="root"} 0
94+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Idle",vdom="root"} 0
95+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Open confirm",vdom="root"} 0
96+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Open sent",vdom="root"} 0
97+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Active",vdom="root"} 0
98+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Connect",vdom="root"} 1
99+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Established",vdom="root"} 0
100+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Idle",vdom="root"} 0
101+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Open confirm",vdom="root"} 0
102+
fortigate_bgp_neighbor_ipv4_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Open sent",vdom="root"} 0
36103
`
37104

38105
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
@@ -44,14 +111,35 @@ func TestBGPNeighborsIPv6(t *testing.T) {
44111
c := newFakeClient()
45112
c.prepare("api/v2/monitor/router/bgp/neighbors6", "testdata/router-bgp-neighbors-v6.jsonnet")
46113
r := prometheus.NewPedanticRegistry()
47-
if !testProbe(probeBGPNeighborsIPv6, c, r) {
114+
meta := &TargetMetadata{
115+
VersionMajor: 7,
116+
VersionMinor: 6,
117+
}
118+
if !testProbeWithMetadata(probeBGPNeighborsIPv6, c, meta, r) {
48119
t.Errorf("probeBGPNeighborsIPv6() returned non-success")
49120
}
50121

51122
em := `
52-
# HELP fortigate_bgp_neighbor_ipv6_info Configured bgp neighbor over ipv6, return state as value (1 - Idle, 2 - Connect, 3 - Active, 4 - Open sent, 5 - Open confirm, 6 - Established)
53-
# TYPE fortigate_bgp_neighbor_ipv6_info gauge
54-
fortigate_bgp_neighbor_ipv6_info{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Established",vdom="root"} 6
123+
# HELP fortigate_bgp_neighbor_ipv6_state Configured bgp neighbor over ipv6 state
124+
# TYPE fortigate_bgp_neighbor_ipv6_state gauge
125+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Active",vdom="root"} 0
126+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Connect",vdom="root"} 0
127+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Established",vdom="root"} 1
128+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Idle",vdom="root"} 0
129+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Open confirm",vdom="root"} 0
130+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::2",remote_as="1337",state="Open sent",vdom="root"} 0
131+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Active",vdom="root"} 0
132+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Connect",vdom="root"} 0
133+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Established",vdom="root"} 0
134+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Idle",vdom="root"} 0
135+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Open confirm",vdom="root"} 1
136+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::5",remote_as="1337",state="Open sent",vdom="root"} 0
137+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Active",vdom="root"} 0
138+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Connect",vdom="root"} 0
139+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Established",vdom="root"} 0
140+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Idle",vdom="root"} 0
141+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Open confirm",vdom="root"} 0
142+
fortigate_bgp_neighbor_ipv6_state{admin_status="true",local_ip="fd00::1",neighbor_ip="fd00::7",remote_as="1337",state="Open sent",vdom="root"} 1
55143
`
56144

57145
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# api/v2/monitor/router/bgp/neighbors?vdom=*
2+
[
3+
{
4+
"http_method":"GET",
5+
"results":[
6+
{
7+
"neighbor_ip":"10.0.0.1",
8+
"local_ip":"10.0.0.0",
9+
"remote_as":1337,
10+
"admin_status":true,
11+
"state":"Established",
12+
"type":"ipv4"
13+
}
14+
],
15+
"vdom":"root",
16+
"path":"router",
17+
"name":"bgp",
18+
"action":"neighbors",
19+
"status":"success",
20+
"serial":"FGT61FT000000000",
21+
"version":"v7.0.0",
22+
"build":66
23+
}
24+
]

pkg/probe/testdata/router-bgp-neighbors-v4.jsonnet

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@
66
{
77
"neighbor_ip":"10.0.0.1",
88
"local_ip":"10.0.0.0",
9-
"remote_as":1337,
9+
"remote_as":"1337",
1010
"admin_status":true,
1111
"state":"Established",
1212
"type":"ipv4"
13+
},
14+
{
15+
"neighbor_ip":"fd00::5",
16+
"local_ip":"fd00::1",
17+
"remote_as":"1337",
18+
"admin_status":true,
19+
"state":"Active",
20+
"type":"ipv6"
21+
},
22+
{
23+
"neighbor_ip":"fd00::7",
24+
"local_ip":"fd00::1",
25+
"remote_as":"1337",
26+
"admin_status":true,
27+
"state":"Connect",
28+
"type":"ipv6"
1329
}
1430
],
1531
"vdom":"root",

0 commit comments

Comments
 (0)