[TASK] new data by respondd
This commit is contained in:
parent
55efa5f8bc
commit
a092b21c05
@ -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"`
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user