fixed bgp collector (#12)

This commit is contained in:
Daniel Czerwonk
2018-05-21 22:56:21 +02:00
committed by Steve Brunton
parent 39e54be98d
commit eb9269527d
2 changed files with 6 additions and 10 deletions

View File

@@ -67,17 +67,13 @@ func (c *bgpCollector) fetch(ctx *collectorContext) ([]*proto.Sentence, error) {
}
func (c *bgpCollector) collectForStat(re *proto.Sentence, ctx *collectorContext) {
var session, asn string
for _, p := range c.props {
if p == "name" {
session = re.Map[p]
} else if p == "remote-as" {
asn = re.Map[p]
} else {
asn := re.Map["remote-as"]
session := re.Map["name"]
for _, p := range c.props[2:] {
c.collectMetricForProperty(p, session, asn, re, ctx)
}
}
}
func (c *bgpCollector) collectMetricForProperty(property, session, asn string, re *proto.Sentence, ctx *collectorContext) {
desc := c.descriptions[property]

View File

@@ -46,7 +46,7 @@ type collector struct {
// WithBGP enables BGP routing metrics
func WithBGP() Option {
return func(c *collector) {
c.collectors = append(c.collectors, &bgpCollector{})
c.collectors = append(c.collectors, newBGPCollector())
}
}