From 1e8ffbeb738153fb19587fe763ff2ff9ab093760 Mon Sep 17 00:00:00 2001 From: Victor1319 Date: Mon, 4 Nov 2024 15:28:14 +0800 Subject: [PATCH] refactor(client): if subdir is empty from cfg file, use cfg from option. Signed-off-by: Victor1319 --- client/fuse.go | 5 +++++ util/exporter/exporter.go | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/fuse.go b/client/fuse.go index 56df10f3a..48223e51b 100644 --- a/client/fuse.go +++ b/client/fuse.go @@ -541,6 +541,11 @@ func main() { } } + if cfg.GetString(exporter.ConfigKeySubDir) == "" { + cfg.SetString(exporter.ConfigKeySubDir, opt.SubDir) + syslog.Printf("config subdir empty, use cfg from mnt, subdir %s", opt.SubDir) + } + exporter.Init(ModuleName, cfg) exporter.RegistConsul(super.ClusterName(), ModuleName, cfg) metric := exporter.NewVersionMetrics(ModuleName) diff --git a/util/exporter/exporter.go b/util/exporter/exporter.go index 36426cd49..2091dc626 100644 --- a/util/exporter/exporter.go +++ b/util/exporter/exporter.go @@ -44,6 +44,7 @@ const ( ConfigKeyEnablePid = "enablePid" // enable report partition id ConfigKeyPushAddr = "pushAddr" // enable push data to gateway ChSize = 1024 * 10 // collect chan size + ConfigKeySubDir = "subdir" // monitor label name Vol = "vol" @@ -161,12 +162,12 @@ func RegistConsul(cluster string, role string, cfg *config.Config) { return } - rawmnt := cfg.GetString("subdir") + rawmnt := cfg.GetString(ConfigKeySubDir) if rawmnt == "" { rawmnt = "/" } mountPoint, _ := filepath.Abs(rawmnt) - log.LogInfof("RegistConsul:%v", enablePush) + log.LogWarnf("RegistConsul:%v, subdir %s", enablePush, mountPoint) if enablePush { log.LogWarnf("[RegisterConsul] use auto push data strategy, not register consul") autoPush(pushAddr, role, cluster, host, mountPoint)