Skip to content

Commit

Permalink
Add hostnames to database-output of link
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lemoer committed Mar 26, 2021
1 parent 4103535 commit 0325aad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions database/influxdb/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions runtime/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 13 additions & 2 deletions runtime/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 0325aad

Please sign in to comment.