summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/megacli/init.go
blob: 78b7bf4826fa56cea65bddbcb4c4cfd5bff2e1be (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 megacli

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

	"github.com/netdata/netdata/go/plugins/pkg/executable"
)

func (m *MegaCli) initMegaCliExec() (megaCli, error) {
	ndsudoPath := filepath.Join(executable.Directory, "ndsudo")

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

	megaExec := newMegaCliExec(ndsudoPath, m.Timeout.Duration(), m.Logger)

	return megaExec, nil
}