diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/zfspool/init.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/zfspool/init.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/zfspool/init.go b/src/go/collectors/go.d.plugin/modules/zfspool/init.go new file mode 100644 index 0000000000..d4debe3fa0 --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/zfspool/init.go @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package zfspool + +import ( + "errors" + "os" + "os/exec" + "strings" +) + +func (z *ZFSPool) validateConfig() error { + if z.BinaryPath == "" { + return errors.New("no zpool binary path specified") + } + return nil +} + +func (z *ZFSPool) initZPoolCLIExec() (zpoolCLI, error) { + binPath := z.BinaryPath + + if !strings.HasPrefix(binPath, "/") { + path, err := exec.LookPath(binPath) + if err != nil { + return nil, err + } + binPath = path + } + + if _, err := os.Stat(binPath); err != nil { + return nil, err + } + + zpoolExec := newZpoolCLIExec(binPath, z.Timeout.Duration()) + + return zpoolExec, nil +} |