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

//go:build linux

package dmcache

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

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

func (c *DmCache) initDmsetupCLI() (dmsetupCLI, error) {
	ndsudoPath := filepath.Join(executable.Directory, "ndsudo")
	if _, err := os.Stat(ndsudoPath); err != nil {
		return nil, fmt.Errorf("ndsudo executable not found: %v", err)

	}

	dmsetup := newDmsetupExec(ndsudoPath, c.Timeout.Duration(), c.Logger)

	return dmsetup, nil
}