From 49dabb35f0edf7630e6352439b28535eeeacc880 Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 20 Nov 2023 17:06:53 +0900 Subject: [PATCH] =?UTF-8?q?proc/stat=20=EB=B6=84=ED=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metric/metric.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/metric/metric.go b/metric/metric.go index 50c9de2..bad70fc 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -9,6 +9,7 @@ import ( "math" "os" "path" + "strings" "sync/atomic" "repositories.action2quare.com/ayo/gocommon/logger" @@ -113,7 +114,10 @@ func init() { if parent, _ := os.FindProcess(ppid); parent != nil { filename := fmt.Sprintf(`/proc/%d/stat`, os.Getppid()) if fn, err := os.ReadFile(filename); err == nil { - if path.Base(string(fn)) == "houston" { + stats := strings.SplitN(string(fn), " ", 3) + parentname := strings.Trim(stats[1], "()") + + if path.Base(parentname) == "houston" { logger.Println("metrics are going to be generated for houston") go mc.metricWriter() NewMetric = newMetricImpl