summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-23 22:21:53 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-27 12:36:29 +0900
commitd321b9a628fe0482dcca3abce5609429d61825ef (patch)
tree80904cc145a019fef0e20a25c15b5492a10c9f09 /server
parent0ef14bb14bfb600957325cde65d59a650ff9bff1 (diff)
collector: doesn't write empty fields
Avoid writing empty fields with a withdraw message. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/collector.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/collector.go b/server/collector.go
index 72f820c0..92ec8fba 100644
--- a/server/collector.go
+++ b/server/collector.go
@@ -116,10 +116,14 @@ func path2data(path *table.Path) (map[string]interface{}, map[string]string) {
tags := map[string]string{
"PeerAddress": path.GetSource().Address.String(),
"PeerAS": fmt.Sprintf("%v", path.GetSource().AS),
- "NextHop": path.GetNexthop().String(),
- "OriginAS": fmt.Sprintf("%v", path.GetSourceAs()),
"Timestamp": path.GetTimestamp().String(),
}
+ if nexthop := path.GetNexthop(); len(nexthop) > 0 {
+ fields["NextHop"] = nexthop.String()
+ }
+ if originAS := path.GetSourceAs(); originAS != 0 {
+ fields["OriginAS"] = fmt.Sprintf("%v", originAS)
+ }
if err := bgp.FlatUpdate(tags, path.GetNlri().Flat()); err != nil {
log.Error(err)