From c34cb485bd85a8e0ae1369c3c41918d1a9cab417 Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 20 Nov 2023 16:39:39 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=ED=8A=B8=EB=A6=AD=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metric/metric.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/metric/metric.go b/metric/metric.go index 2b17129..b139af6 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -8,6 +8,7 @@ import ( "fmt" "math" "os" + "path" "sync/atomic" "repositories.action2quare.com/ayo/gocommon/logger" @@ -101,22 +102,29 @@ func init() { return &metric_empty{} } + if path.Base(os.Args[0]) == "houston" { + logger.Println("metrics are going to be generated for myself(houston)") + go mc.metricWriter() + NewMetric = newMetricImpl + return + } + ppid := os.Getppid() if parent, _ := os.FindProcess(ppid); parent != nil { filename := fmt.Sprintf(`/proc/%d/stat`, os.Getppid()) if fn, err := os.ReadFile(filename); err == nil { - if string(fn) == "houston" { - logger.Println("metrics are activated for houston") + if path.Base(string(fn)) == "houston" { + logger.Println("metrics are going to be generated for houston") go mc.metricWriter() NewMetric = newMetricImpl } else { - logger.Println("metrics are NOT activated") + logger.Println("metrics are NOT going to be generated. parent is not houston") } } else { - logger.Println("metrics are NOT activated") + logger.Println("metrics are NOT going to be generated. ppid proc is missing :", filename) } } else { - logger.Println("metrics are NOT activated") + logger.Println("metrics are NOT going to be generated. parent process is missing. ppid :", ppid) } }