mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 23:36:18 +08:00
collect metrics by server
This commit is contained in:
parent
82f0afe9d7
commit
26f9c2525c
4
go.mod
4
go.mod
|
@ -29,7 +29,7 @@ require (
|
|||
require (
|
||||
filippo.io/edwards25519 v1.0.0
|
||||
github.com/c-robinson/iplib v1.0.6
|
||||
github.com/go-ping/ping v1.1.0
|
||||
github.com/go-ping/ping v1.1.0 // indirect
|
||||
github.com/posthog/posthog-go v0.0.0-20211028072449-93c17c49e2b0
|
||||
)
|
||||
|
||||
|
@ -43,7 +43,7 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/gravitl/netclient v0.0.0-20230111052236-026a8d6b2a76
|
||||
github.com/gravitl/netclient v0.0.0-20230111161447-b0ba3981a25f
|
||||
github.com/guumaster/tablewriter v0.0.10
|
||||
github.com/matryer/is v1.4.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
// Collect - collects metrics
|
||||
func Collect(iface, network string, proxy bool, peerMap models.PeerMap) (*models.Metrics, error) {
|
||||
func Collect(iface, server, network string, proxy bool, peerMap models.PeerMap) (*models.Metrics, error) {
|
||||
var metrics models.Metrics
|
||||
metrics.Connectivity = make(map[string]models.Metric)
|
||||
var wgclient, err = wgctrl.New()
|
||||
|
@ -28,13 +28,16 @@ func Collect(iface, network string, proxy bool, peerMap models.PeerMap) (*models
|
|||
// TODO handle freebsd??
|
||||
for i := range device.Peers {
|
||||
currPeer := device.Peers[i]
|
||||
if _, ok := peerMap[currPeer.PublicKey.String()]; !ok {
|
||||
continue
|
||||
}
|
||||
id := peerMap[currPeer.PublicKey.String()].ID
|
||||
address := peerMap[currPeer.PublicKey.String()].Address
|
||||
if id == "" || address == "" {
|
||||
logger.Log(0, "attempted to parse metrics for invalid peer from server", id, address)
|
||||
continue
|
||||
}
|
||||
proxyMetrics := proxy_metrics.GetMetric(currPeer.PublicKey.String())
|
||||
proxyMetrics := proxy_metrics.GetMetric(server, currPeer.PublicKey.String())
|
||||
var newMetric = models.Metric{
|
||||
NodeName: peerMap[currPeer.PublicKey.String()].Name,
|
||||
IsServer: peerMap[currPeer.PublicKey.String()].IsServer,
|
||||
|
@ -60,9 +63,9 @@ func Collect(iface, network string, proxy bool, peerMap models.PeerMap) (*models
|
|||
newMetric.TotalTime = 1
|
||||
metrics.Connectivity[id] = newMetric
|
||||
if len(proxyMetrics.NodeConnectionStatus) == 1 {
|
||||
proxy_metrics.ResetMetricsForPeer(currPeer.PublicKey.String())
|
||||
proxy_metrics.ResetMetricsForPeer(server, currPeer.PublicKey.String())
|
||||
} else {
|
||||
proxy_metrics.ResetMetricForNode(currPeer.PublicKey.String(), id)
|
||||
proxy_metrics.ResetMetricForNode(server, currPeer.PublicKey.String(), id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue