From a092b21c0503fc989f134b00fd78416764233bea Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Fri, 30 Jun 2017 07:44:39 +0200 Subject: [PATCH] [TASK] new data by respondd --- data/neighbours.go | 17 +++++++++++++---- database/graphite/node.go | 7 +++++++ database/influxdb/node.go | 7 +++++++ meshviewer/graph.go | 17 +++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/data/neighbours.go b/data/neighbours.go index 08fd0d2..24d7f18 100644 --- a/data/neighbours.go +++ b/data/neighbours.go @@ -2,10 +2,11 @@ package data // Neighbours struct type Neighbours struct { - Batadv map[string]BatadvNeighbours `json:"batadv"` - LLDP map[string]LLDPNeighbours `json:"lldp"` - //WifiNeighbours map[string]WifiNeighbours `json:"wifi"` - NodeID string `json:"node_id"` + Batadv map[string]BatadvNeighbours `json:"batadv"` + LLDP map[string]LLDPNeighbours `json:"lldp"` + Babel map[string]BabelNeighbours `json:"babel"` + WifiNeighbours map[string]WifiNeighbours `json:"wifi"` + NodeID string `json:"node_id"` } // WifiLink struct @@ -21,6 +22,11 @@ type BatmanLink struct { Tq int `json:"tq"` } +// BabelLink struct +type BabelLink struct { + Address string `json:"address"` +} + // LLDPLink struct type LLDPLink struct { Name string `json:"name"` @@ -32,6 +38,9 @@ type BatadvNeighbours struct { Neighbours map[string]BatmanLink `json:"neighbours"` } +// BabelNeighbours struct +type BabelNeighbours []BabelLink + // WifiNeighbours struct type WifiNeighbours struct { Neighbours map[string]WifiLink `json:"neighbours"` diff --git a/database/graphite/node.go b/database/graphite/node.go index 2b04e9a..1ca52a8 100644 --- a/database/graphite/node.go +++ b/database/graphite/node.go @@ -50,6 +50,13 @@ func (c *Connection) InsertNode(node *runtime.Node) { } addField("neighbours.batadv", batadv) + // protocol: Babel + babel := 0 + for _, babelNeighbours := range neighbours.Babel { + babel += len(babelNeighbours) + } + addField("neighbours.babel", babel) + // protocol: LLDP lldp := 0 for _, lldpNeighbours := range neighbours.LLDP { diff --git a/database/influxdb/node.go b/database/influxdb/node.go index 5f23368..21a23e4 100644 --- a/database/influxdb/node.go +++ b/database/influxdb/node.go @@ -80,6 +80,13 @@ func buildNodeStats(node *runtime.Node) (tags models.Tags, fields models.Fields) } fields["neighbours.batadv"] = batadv + // protocol: Babel + babel := 0 + for _, babelNeighbours := range neighbours.Babel { + babel += len(babelNeighbours) + } + fields["neighbours.babel"] = babel + // protocol: LLDP lldp := 0 for _, lldpNeighbours := range neighbours.LLDP { diff --git a/meshviewer/graph.go b/meshviewer/graph.go index dda0d3a..3386cd3 100644 --- a/meshviewer/graph.go +++ b/meshviewer/graph.go @@ -80,6 +80,7 @@ func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) { builder.macToID[sourceAddress] = sourceID } } + } // Iterate over local MAC addresses from LLDP @@ -102,6 +103,22 @@ func (builder *graphBuilder) readNodes(nodes map[string]*runtime.Node) { } } } + // Wifi neighbours + for _, wifiNeighbours := range neighbours.WifiNeighbours { + for targetAddress, link := range wifiNeighbours.Neighbours { + if targetID, found := builder.macToID[targetAddress]; found { + builder.addLink(targetID, sourceID, link.Noise/link.Signal) + } + } + } + // Babel neighbours + for _, babelNeighbours := range neighbours.Babel { + for _, link := range babelNeighbours { + if targetID, found := builder.macToID[link.Address]; found { + builder.addLink(targetID, sourceID, 1) + } + } + } // LLDP for _, neighbours := range neighbours.LLDP { for targetAddress := range neighbours {