diff --git a/src/modules/collector/sys/plugins/reader.go b/src/modules/collector/sys/plugins/reader.go index 39b72929..78eca0e5 100644 --- a/src/modules/collector/sys/plugins/reader.go +++ b/src/modules/collector/sys/plugins/reader.go @@ -32,6 +32,7 @@ func ListPlugins(dir string) map[string]*Plugin { filename := f.Name() arr := strings.Split(filename, "_") if len(arr) < 2 { + logger.Warningf("plugin:%s name illegal, should be: $cycle_$xx", filename) continue } @@ -39,10 +40,16 @@ func ListPlugins(dir string) map[string]*Plugin { var cycle int cycle, err = strconv.Atoi(arr[0]) if err != nil { + logger.Warningf("plugin:%s name illegal, should be: $cycle_$xx %v", filename, err) + continue + } + + fpath, err := filepath.Abs(filepath.Join(dir, filename)) + if err != nil { + logger.Warningf("plugin:%s absolute path get err:%v", filename, err) continue } - fpath := filepath.Join(dir, filename) plugin := &Plugin{FilePath: fpath, MTime: f.ModTime().Unix(), Cycle: cycle} ret[fpath] = plugin } diff --git a/src/modules/collector/sys/plugins/scheduler.go b/src/modules/collector/sys/plugins/scheduler.go index 22e68a01..f771b5e1 100644 --- a/src/modules/collector/sys/plugins/scheduler.go +++ b/src/modules/collector/sys/plugins/scheduler.go @@ -50,8 +50,7 @@ func PluginRun(plugin *Plugin) { timeout := plugin.Cycle*1000 - 500 //比运行周期少500毫秒 - fpath := filepath.Join(file.SelfDir(), plugin.FilePath) - + fpath := plugin.FilePath if !file.IsExist(fpath) { logger.Error("no such plugin:", fpath) return