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