Skip to content

Commit

Permalink
community monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Sep 3, 2024
1 parent 2c7e30e commit 0592572
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lg.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ var (
Name: "possible_hijack",
Help: "upstream mismatch, possible hijack",
})
//bgpCommunitiesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
// Name: "bgp_communities",
// Help: "BGP Communities",
//},
// []string{"prefix", "city", "mux", "communities"},
//)
bgpCommunitiesGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "bgp_communities",
Help: "BGP Communities",
},
[]string{"prefix", "city", "mux", "communities"},
)
)

func (p *Prefix) checkLGState() {
Expand Down Expand Up @@ -80,7 +80,7 @@ func (p *Prefix) checkLGState() {
for _, rrc := range ripeStatLookingGlassResp.Data.Rrcs {
upstreams := []string{}
upstreams2 := []string{}
//communities := []string{}
communities := []string{}

for _, peer := range rrc.Peers {
asPathSplit := strings.Split(peer.AsPath, " ")
Expand Down Expand Up @@ -146,7 +146,7 @@ func (p *Prefix) checkLGState() {
if !slices.Contains(upstreams2, upstream2) {
upstreams2 = append(upstreams2, upstream2)
}
//communities = append(communities, peer.Community)
communities = append(communities, peer.Community)
}

upstreamsGauge.WithLabelValues(
Expand All @@ -165,14 +165,14 @@ func (p *Prefix) checkLGState() {
origin,
).Set(float64(len(upstreams2)))

//communities = slices.Compact(communities)
//for _, e := range communities {
// bgpCommunitiesGauge.WithLabelValues(
// p.prefix,
// rrc.Location,
// prefixes[p.prefix],
// e,
// ).Set(1)
//}
communities = slices.Compact(communities)
for _, e := range communities {
bgpCommunitiesGauge.WithLabelValues(
p.prefix,
rrc.Location,
p.pop,
e,
).Set(1)
}
}
}
2 changes: 2 additions & 0 deletions prefixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var dbUpstreams = []Upstream{
}

var monitorState = []Prefix{
Prefix{prefix: "184.164.250.0/24", pop: "rotate", available: true, origin: 47065},
Prefix{prefix: "184.164.251.0/24", pop: "rotate", available: true, origin: 47065},
Prefix{prefix: "2804:269c:fe01::/48", pop: "seattle01", available: true, origin: 47065},
Prefix{prefix: "2804:269c:fe02::/48", pop: "isi01", available: true, origin: 47065},
Prefix{prefix: "2804:269c:fe03::/48", pop: "cornell01", available: false, origin: 47065},
Expand Down

0 comments on commit 0592572

Please sign in to comment.