agent: use const for input file prefix

This commit is contained in:
kun 2022-06-04 16:21:53 +08:00
parent 31ae053212
commit f86a536e5c
1 changed files with 5 additions and 3 deletions

View File

@ -42,6 +42,8 @@ import (
_ "flashcat.cloud/categraf/inputs/tomcat"
)
const inputFilePrefix = "input."
type Agent struct {
InputFilters map[string]struct{}
}
@ -107,7 +109,7 @@ func (a *Agent) startInputs() error {
// construct input instance
instance := creator()
// set configurations for input instance
cfg.LoadConfigs(path.Join(config.Config.ConfigDir, "input."+name), instance)
cfg.LoadConfigs(path.Join(config.Config.ConfigDir, inputFilePrefix+name), instance)
if err = instance.Init(); err != nil {
if !errors.Is(err, types.ErrInstancesEmpty) {
@ -145,8 +147,8 @@ func (a *Agent) getInputsByDirs() ([]string, error) {
names := make([]string, 0, count)
for i := 0; i < count; i++ {
if strings.HasPrefix(dirs[i], "input.") {
names = append(names, dirs[i][6:])
if strings.HasPrefix(dirs[i], inputFilePrefix) {
names = append(names, dirs[i][len(inputFilePrefix):])
}
}