From 7f66ffa176c2cda6659af25a2c31fe7692af444b Mon Sep 17 00:00:00 2001 From: askuy Date: Thu, 6 Jun 2024 13:47:06 +0800 Subject: [PATCH] tcp stat ipv4 --- core/emetric/tcpstat.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/emetric/tcpstat.go b/core/emetric/tcpstat.go index 4b3ec00..19b46c3 100644 --- a/core/emetric/tcpstat.go +++ b/core/emetric/tcpstat.go @@ -129,7 +129,7 @@ func getTCPStats(statsFile string) (map[tcpConnectionState]map[string]float64, e func parseTCPStats(r io.Reader) (map[tcpConnectionState]map[string]float64, error) { //tcpStats := map[tcpConnectionState]float64{} - tcpStatsMap := map[tcpConnectionState]map[string]float64{} + tcpStatsMap := make(map[tcpConnectionState]map[string]float64, 0) contents, err := io.ReadAll(r) if err != nil { return nil, err @@ -169,6 +169,7 @@ func parseTCPStats(r io.Reader) (map[tcpConnectionState]map[string]float64, erro info, flag := tcpStatsMap[tcpConnectionState(st)] if !flag { + info = make(map[string]float64, 0) info[ipv4] = 1 } else { info[ipv4]++