diff --git a/database/influxdb/link.go b/database/influxdb/link.go index 1d642ba..37c2bd9 100644 --- a/database/influxdb/link.go +++ b/database/influxdb/link.go @@ -14,6 +14,12 @@ func (conn *Connection) InsertLink(link *runtime.Link, t time.Time) { tags.SetString("source.addr", link.SourceAddress) tags.SetString("target.id", link.TargetID) tags.SetString("target.addr", link.TargetAddress) + if link.SourceHostname != "" { + tags.SetString("source.hostname", link.SourceHostname) + } + if link.TargetHostname != "" { + tags.SetString("target.hostname", link.TargetHostname) + } conn.addPoint(MeasurementLink, tags, models.Fields{"tq": link.TQ * 100}, t) } diff --git a/runtime/node.go b/runtime/node.go index cb55738..d048639 100644 --- a/runtime/node.go +++ b/runtime/node.go @@ -22,9 +22,11 @@ type Node struct { // Link represents a link between two nodes type Link struct { SourceID string + SourceHostname string SourceAddress string TargetID string TargetAddress string + TargetHostname string TQ float32 } diff --git a/runtime/nodes.go b/runtime/nodes.go index 3dae12d..069e804 100644 --- a/runtime/nodes.go +++ b/runtime/nodes.go @@ -117,13 +117,24 @@ func (nodes *Nodes) NodeLinks(node *Node) (result []Link) { for sourceMAC, batadv := range neighbours.Batadv { for neighbourMAC, link := range batadv.Neighbours { if neighbourID := nodes.ifaceToNodeID[neighbourMAC]; neighbourID != "" { - result = append(result, Link{ + neighbour := nodes.List[neighbours.NodeID] + + link := Link{ SourceID: neighbours.NodeID, SourceAddress: sourceMAC, TargetID: neighbourID, TargetAddress: neighbourMAC, TQ: float32(link.Tq) / 255.0, - }) + } + + if neighbour.Nodeinfo != nil { + link.SourceHostname = neighbour.Nodeinfo.Hostname + } + if node.Nodeinfo != nil { + link.TargetHostname = node.Nodeinfo.Hostname + } + + result = append(result, link) } } }