From 3951fc2bd3c5ecf7d9546423c0ea6b18c94e162d Mon Sep 17 00:00:00 2001 From: askuy Date: Fri, 7 Jun 2024 12:19:26 +0800 Subject: [PATCH] EnableConnTcpMetric --- core/emetric/tcpstat.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/emetric/tcpstat.go b/core/emetric/tcpstat.go index b49ec05..4fe2414 100644 --- a/core/emetric/tcpstat.go +++ b/core/emetric/tcpstat.go @@ -68,13 +68,13 @@ func NewTCPStatCollector() (*TcpStatCollector, error) { func (c *TcpStatCollector) Update() error { go func() { - statsFile := path.Join("/proc", strconv.Itoa(os.Getpid()), "net", "tcp") - tcpStats, err := getTCPStats(statsFile) - if err != nil { - elog.EgoLogger.Error(fmt.Errorf("couldn't get tcpstats: %w", err).Error()) - return - } for { + statsFile := path.Join("/proc", strconv.Itoa(os.Getpid()), "net", "tcp") + tcpStats, err := getTCPStats(statsFile) + if err != nil { + elog.EgoLogger.Error(fmt.Errorf("couldn't get tcpstats: %w", err).Error()) + return + } for index, value := range tcpStats { for addr, number := range value { ClientStatsGauge.WithLabelValues( @@ -83,8 +83,8 @@ func (c *TcpStatCollector) Update() error { index.String(), ).Set(number) } - time.Sleep(5 * time.Second) } + time.Sleep(5 * time.Second) } }()