summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/storcli/init.go
blob: 297f7c8c3e3a046a06ed766e772feb04e09f8fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: GPL-3.0-or-later

package storcli

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/netdata/netdata/go/go.d.plugin/agent/executable"
)

func (s *StorCli) initStorCliExec() (storCli, error) {
	ndsudoPath := filepath.Join(executable.Directory, "ndsudo")

	if _, err := os.Stat(ndsudoPath); err != nil {
		return nil, fmt.Errorf("ndsudo executable not found: %v", err)
	}

	storExec := newStorCliExec(ndsudoPath, s.Timeout.Duration(), s.Logger)

	return storExec, nil
}