influxdb: add site_code tag to node

This commit is contained in:
Julian Labus 2017-11-11 22:21:53 +01:00
parent 93321ab3ad
commit 86e6347b06
2 changed files with 7 additions and 0 deletions

View File

@ -49,6 +49,9 @@ func (conn *Connection) InsertNode(node *runtime.Node) {
if nodeinfo := node.Nodeinfo; nodeinfo != nil { if nodeinfo := node.Nodeinfo; nodeinfo != nil {
tags.SetString("hostname", nodeinfo.Hostname) tags.SetString("hostname", nodeinfo.Hostname)
if len(nodeinfo.System.SiteCode) > 0 {
tags.SetString("site_code", nodeinfo.System.SiteCode)
}
if owner := nodeinfo.Owner; owner != nil { if owner := nodeinfo.Owner; owner != nil {
tags.SetString("owner", owner.Contact) tags.SetString("owner", owner.Contact)
} }

View File

@ -51,6 +51,9 @@ func TestToInflux(t *testing.T) {
Owner: &data.Owner{ Owner: &data.Owner{
Contact: "nobody", Contact: "nobody",
}, },
System: &data.System{
SiteCode: "ffhb",
},
Wireless: &data.Wireless{ Wireless: &data.Wireless{
TxPower24: 3, TxPower24: 3,
Channel24: 4, Channel24: 4,
@ -97,6 +100,7 @@ func TestToInflux(t *testing.T) {
assert.EqualValues("deadbeef", tags["nodeid"]) assert.EqualValues("deadbeef", tags["nodeid"])
assert.EqualValues("nobody", tags["owner"]) assert.EqualValues("nobody", tags["owner"])
assert.EqualValues("ffhb", tags["site_code"])
assert.EqualValues(0.5, fields["load"]) assert.EqualValues(0.5, fields["load"])
assert.EqualValues(0, fields["neighbours.lldp"]) assert.EqualValues(0, fields["neighbours.lldp"])
assert.EqualValues(1, fields["neighbours.batadv"]) assert.EqualValues(1, fields["neighbours.batadv"])