Add hostnames to database-output of link
Grafana is currently not able to resolve the target.id or source.id into a human readable hostname. Therefore reading the neighbour graphs is quite difficult for humans. To resolve this, we add the additional tags source.hostname and target.hostname to the influx link measurements. In PR #197
This commit is contained in:
parent
4103535992
commit
0325aad24e
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue