From 5d6f046e39780452cca65bf5888c7a83f588df00 Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Sat, 18 Feb 2017 23:51:24 +0100 Subject: [PATCH] [influxdb] site_code tag to node --- database/influxdb/node.go | 3 +++ database/influxdb/node_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/database/influxdb/node.go b/database/influxdb/node.go index 9b17f59..23a9a0b 100644 --- a/database/influxdb/node.go +++ b/database/influxdb/node.go @@ -31,6 +31,9 @@ func nodeToInflux(node *runtime.Node) (tags models.Tags, fields models.Fields) { if nodeinfo := node.Nodeinfo; nodeinfo != nil { tags.SetString("hostname", nodeinfo.Hostname) + if len(nodeinfo.System.SiteCode) > 0 { + tags.SetString("site_code", nodeinfo.System.SiteCode) + } if owner := nodeinfo.Owner; owner != nil { tags.SetString("owner", owner.Contact) } diff --git a/database/influxdb/node_test.go b/database/influxdb/node_test.go index 08dc06c..b4204ad 100644 --- a/database/influxdb/node_test.go +++ b/database/influxdb/node_test.go @@ -49,6 +49,9 @@ func TestToInflux(t *testing.T) { Owner: &data.Owner{ Contact: "nobody", }, + System: data.System{ + SiteCode: "ffhb", + }, Wireless: &data.Wireless{ TxPower24: 3, Channel24: 4, @@ -70,6 +73,7 @@ func TestToInflux(t *testing.T) { assert.Equal("foobar", tags.GetString("nodeid")) assert.Equal("nobody", tags.GetString("owner")) + assert.Equal("ffhb", tags.GetString("site_code")) assert.Equal(0.5, fields["load"]) assert.Equal(0, fields["neighbours.lldp"]) assert.Equal(1, fields["neighbours.batadv"])