mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-10 00:30:37 +08:00
dump metrics for testing
This commit is contained in:
parent
bcbe355281
commit
3f7ca6c83e
1 changed files with 14 additions and 0 deletions
|
|
@ -1,12 +1,18 @@
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gravitl/netmaker/models"
|
"github.com/gravitl/netmaker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
go dumpMetrics()
|
||||||
|
}
|
||||||
|
|
||||||
// lock for metrics map
|
// lock for metrics map
|
||||||
var metricsMapLock = &sync.RWMutex{}
|
var metricsMapLock = &sync.RWMutex{}
|
||||||
|
|
||||||
|
|
@ -81,3 +87,11 @@ func ResetMetricForNode(server, peerKey, peerID string) {
|
||||||
|
|
||||||
// MetricCollectionInterval - collection interval for metrics
|
// MetricCollectionInterval - collection interval for metrics
|
||||||
const MetricCollectionInterval = time.Second * 25
|
const MetricCollectionInterval = time.Second * 25
|
||||||
|
|
||||||
|
func dumpMetrics() {
|
||||||
|
for {
|
||||||
|
time.Sleep(time.Second * 35)
|
||||||
|
d, _ := json.MarshalIndent(metricsPeerMap, "", " ")
|
||||||
|
os.WriteFile("/tmp/metrics.json", d, 0755)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue