[TASK] new data by respondd

This commit is contained in:
Martin Geno 2017-06-30 07:44:39 +02:00
parent 55efa5f8bc
commit a092b21c05
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
4 changed files with 44 additions and 4 deletions

View File

@ -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"`

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {