From 5de355b2b1a4b7253267415764daeec78db21fa8 Mon Sep 17 00:00:00 2001 From: yanli <38203792+tianyanli@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:56:02 +0800 Subject: [PATCH] Update netstat_filter.go --- inputs/netstat_filter/netstat_filter.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inputs/netstat_filter/netstat_filter.go b/inputs/netstat_filter/netstat_filter.go index 81c1dbe8..bfb59c96 100644 --- a/inputs/netstat_filter/netstat_filter.go +++ b/inputs/netstat_filter/netstat_filter.go @@ -12,7 +12,7 @@ import ( ) const inputName = "netstat_filter" - +var executed = false type NetStatFilter struct { config.PluginConfig Instances []*Instance `toml:"instances"` @@ -115,7 +115,11 @@ func (ins *Instance) Gather(slist *types.SampleList) { send = value.Txq recv = value.Rxq } else { - log.Println("E! Key not matched, TCP_ Send_ Queue, TCP_ Recv_Queue, The queue value is 0") + if !executed { + // 执行只需要在启动后执行一次的代码 + log.Println("E! init Key not matched, TCP_ Send_ Queue, TCP_ Recv_Queue, The queue value is 0,key:", key) + executed = true + } } fields := map[string]interface{}{