diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/go/plugin/go.d/modules/zfspool/init.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-87d772a7d708fec12f48cd8adc0dedff6e1025da.tar.xz netdata-87d772a7d708fec12f48cd8adc0dedff6e1025da.zip |
Adding upstream version 1.47.0.upstream/1.47.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/plugin/go.d/modules/zfspool/init.go')
-rw-r--r-- | src/go/plugin/go.d/modules/zfspool/init.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/zfspool/init.go b/src/go/plugin/go.d/modules/zfspool/init.go new file mode 100644 index 000000000..f640801dd --- /dev/null +++ b/src/go/plugin/go.d/modules/zfspool/init.go @@ -0,0 +1,38 @@ +// 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()) + zpoolExec.Logger = z.Logger + + return zpoolExec, nil +} |