fix neighbour to influxdb
This commit is contained in:
parent
2380c7de9a
commit
724cd8ba51
|
@ -57,7 +57,7 @@ func (node *Node) ToInflux() (tags imodels.Tags, fields imodels.Fields) {
|
||||||
if meshvpn := stats.MeshVPN; meshvpn != nil {
|
if meshvpn := stats.MeshVPN; meshvpn != nil {
|
||||||
for _, group := range meshvpn.Groups {
|
for _, group := range meshvpn.Groups {
|
||||||
for _, link := range group.Peers {
|
for _, link := range group.Peers {
|
||||||
if link.Established > 1 {
|
if link != nil && link.Established > 1 {
|
||||||
vpn++
|
vpn++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,10 @@ func (node *Node) ToInflux() (tags imodels.Tags, fields imodels.Fields) {
|
||||||
fields["neighbours.batadv"] = batadv
|
fields["neighbours.batadv"] = batadv
|
||||||
|
|
||||||
// protocol: LLDP
|
// protocol: LLDP
|
||||||
lldp := len(neighbours.LLDP)
|
lldp := 0
|
||||||
|
for _, lldpNeighbours := range neighbours.LLDP {
|
||||||
|
lldp += len(lldpNeighbours)
|
||||||
|
}
|
||||||
fields["neighbours.lldp"] = lldp
|
fields["neighbours.lldp"] = lldp
|
||||||
|
|
||||||
// total is the sum of all protocols
|
// total is the sum of all protocols
|
||||||
|
|
|
@ -36,6 +36,7 @@ func TestToInflux(t *testing.T) {
|
||||||
Peers: map[string]*data.MeshVPNPeerLink{
|
Peers: map[string]*data.MeshVPNPeerLink{
|
||||||
"vpn01": &data.MeshVPNPeerLink{Established: 3},
|
"vpn01": &data.MeshVPNPeerLink{Established: 3},
|
||||||
"vpn02": &data.MeshVPNPeerLink{},
|
"vpn02": &data.MeshVPNPeerLink{},
|
||||||
|
"trash": nil,
|
||||||
"vpn03": &data.MeshVPNPeerLink{Established: 0},
|
"vpn03": &data.MeshVPNPeerLink{Established: 0},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -59,6 +60,7 @@ func TestToInflux(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
LLDP: map[string]data.LLDPNeighbours{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue