diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/smartctl/init.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/smartctl/init.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/smartctl/init.go b/src/go/collectors/go.d.plugin/modules/smartctl/init.go new file mode 100644 index 0000000000..5c6ede5316 --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/smartctl/init.go @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package smartctl + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/netdata/netdata/go/go.d.plugin/agent/executable" +) + +func (s *Smartctl) validateConfig() error { + switch s.NoCheckPowerMode { + case "never", "sleep", "standby", "idle": + default: + return fmt.Errorf("invalid power mode '%s'", s.NoCheckPowerMode) + } + return nil +} + +func (s *Smartctl) initSmartctlCli() (smartctlCli, error) { + ndsudoPath := filepath.Join(executable.Directory, "ndsudo") + if _, err := os.Stat(ndsudoPath); err != nil { + return nil, fmt.Errorf("ndsudo executable not found: %v", err) + + } + + smartctlExec := newSmartctlCliExec(ndsudoPath, s.Timeout.Duration(), s.Logger) + + return smartctlExec, nil +} |