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) } }