master
go 52 lines 1.19 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package hpssa
4
5 import (
6 "time"
7
8 "github.com/netdata/netdata/go/plugins/logger"
9 "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/ndexec"
10 )
11
12 type ssacliBinary interface {
13 controllersInfo() ([]byte, error)
14 }
15
16 // ndsudoSsacliExec executes ssacli via ndsudo (Linux/BSD)
17 type ndsudoSsacliExec struct {
18 *logger.Logger
19
20 timeout time.Duration
21 }
22
23 func newNdsudoSsacliExec(timeout time.Duration, log *logger.Logger) *ndsudoSsacliExec {
24 return &ndsudoSsacliExec{
25 Logger: log,
26 timeout: timeout,
27 }
28 }
29
30 func (e *ndsudoSsacliExec) controllersInfo() ([]byte, error) {
31 return ndexec.RunNDSudo(e.Logger, e.timeout, "ssacli-controllers-info")
32 }
33
34 // directSsacliExec executes ssacli directly (Windows)
35 type directSsacliExec struct {
36 *logger.Logger
37
38 ssacliPath string
39 timeout time.Duration
40 }
41
42 func newDirectSsacliExec(ssacliPath string, timeout time.Duration, log *logger.Logger) *directSsacliExec {
43 return &directSsacliExec{
44 Logger: log,
45 ssacliPath: ssacliPath,
46 timeout: timeout,
47 }
48 }
49
50 func (e *directSsacliExec) controllersInfo() ([]byte, error) {
51 return ndexec.RunDirect(e.Logger, e.timeout, e.ssacliPath, "ctrl", "all", "show", "config", "detail")
52 }