Skip to content

Commit 604dcf3

Browse files
committed
feat: Ability to override commands args
In order to override the arguments which are used e.g. to call smartctl, they need to be bind to the respective environment variable.
1 parent 57dc547 commit 604dcf3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

collector/pkg/config/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ func (c *configuration) Init() error {
4848
c.SetDefault("commands.metrics_info_args", "--info --json")
4949
c.SetDefault("commands.metrics_smart_args", "--xall --json")
5050

51+
// Bind environment variables with COLLECTOR_ prefix
52+
c.BindEnv("host.id", "COLLECTOR_HOST_ID")
53+
c.BindEnv("log.level", "COLLECTOR_LOG_LEVEL")
54+
c.BindEnv("log.file", "COLLECTOR_LOG_FILE")
55+
c.BindEnv("api.endpoint", "COLLECTOR_API_ENDPOINT")
56+
c.BindEnv("commands.metrics_smartctl_bin", "COLLECTOR_COMMANDS_METRICS_SMARTCTL_BIN")
57+
c.BindEnv("commands.metrics_scan_args", "COLLECTOR_COMMANDS_METRICS_SCAN_ARGS")
58+
c.BindEnv("commands.metrics_info_args", "COLLECTOR_COMMANDS_METRICS_INFO_ARGS")
59+
c.BindEnv("commands.metrics_smart_args", "COLLECTOR_COMMANDS_METRICS_SMART_ARGS")
60+
5161
//c.SetDefault("collect.short.command", "-a -o on -S on")
5262

5363
c.SetDefault("allow_listed_devices", []string{})

0 commit comments

Comments
 (0)