[TASK] influxdb: add site tag to node
This commit is contained in:
parent
9720835e60
commit
136b42b468
|
@ -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 nodeinfo.System.SiteCode != "" {
|
||||||
|
tags.SetString("site", 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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ func TestToInflux(t *testing.T) {
|
||||||
Owner: &data.Owner{
|
Owner: &data.Owner{
|
||||||
Contact: "nobody",
|
Contact: "nobody",
|
||||||
},
|
},
|
||||||
|
System: data.System{
|
||||||
|
SiteCode: "ffxx",
|
||||||
|
},
|
||||||
Wireless: &data.Wireless{
|
Wireless: &data.Wireless{
|
||||||
TxPower24: 3,
|
TxPower24: 3,
|
||||||
Channel24: 4,
|
Channel24: 4,
|
||||||
|
@ -128,6 +131,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("testing", tags["autoupdater"])
|
assert.EqualValues("testing", tags["autoupdater"])
|
||||||
|
assert.EqualValues("ffxx", tags["site"])
|
||||||
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"])
|
||||||
|
|
Loading…
Reference in New Issue