summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packet/bgp/bgp.go5
-rw-r--r--server/collector.go16
2 files changed, 10 insertions, 11 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go
index c01859fe..17d11f4e 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -7081,9 +7081,12 @@ func (e *MessageError) Error() string {
}
func (l *LabeledVPNIPAddrPrefix) Flat() map[string]string {
+ prefixLen := l.IPAddrPrefixDefault.Length - uint8(8*(l.Labels.Len()+l.RD.Len()))
return map[string]string{
"Prefix": l.IPAddrPrefixDefault.Prefix.String(),
- "PrefixLen": string(l.IPAddrPrefixDefault.Length - uint8(8*(l.Labels.Len()+l.RD.Len())))}
+ "PrefixLen": fmt.Sprintf("%d", prefixLen),
+ "NLRI": l.String(),
+ }
}
func (p *IPAddrPrefixDefault) Flat() map[string]string {
diff --git a/server/collector.go b/server/collector.go
index 2c0a47da..c1930d09 100644
--- a/server/collector.go
+++ b/server/collector.go
@@ -21,7 +21,6 @@ import (
"github.com/influxdata/influxdb/client/v2"
"github.com/osrg/gobgp/packet/bgp"
"github.com/osrg/gobgp/table"
- "strings"
"time"
)
@@ -111,21 +110,18 @@ func path2data(path *table.Path) (map[string]interface{}, map[string]string) {
fields["Med"] = med
}
- var prefix, prefixLen string
- l := strings.Split(path.GetNlri().String(), "/")
- if len(l) == 2 {
- prefix = l[0]
- prefixLen = l[1]
- }
tags := map[string]string{
"PeerAddress": path.GetSource().Address.String(),
"PeerAS": fmt.Sprintf("%v", path.GetSource().AS),
- "Prefix": prefix,
- "PrefixLen": prefixLen,
"NextHop": path.GetNexthop().String(),
"OriginAS": fmt.Sprintf("%v", path.GetSourceAs()),
"Timestamp": path.GetTimestamp().String(),
}
+
+ flat := path.GetNlri().Flat()
+ for key, value := range flat {
+ tags[key] = value
+ }
return fields, tags
}
@@ -214,7 +210,7 @@ func NewCollector(grpcCh chan *GrpcRequest, url, dbName string, interval uint64)
return nil, err
}
- q := client.NewQuery("CREATE DATABASE " + dbName, "", "")
+ q := client.NewQuery("CREATE DATABASE "+dbName, "", "")
if response, err := c.Query(q); err != nil || response.Error() != nil {
log.Error("can not create database " + dbName)
return nil, err