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/collectors/go.d.plugin/modules/nvidia_smi/exec.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/nvidia_smi/exec.go | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/nvidia_smi/exec.go b/src/go/collectors/go.d.plugin/modules/nvidia_smi/exec.go deleted file mode 100644 index ff26f59c8..000000000 --- a/src/go/collectors/go.d.plugin/modules/nvidia_smi/exec.go +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -package nvidia_smi - -import ( - "context" - "errors" - "fmt" - "os/exec" - "strings" - "time" - - "github.com/netdata/netdata/go/go.d.plugin/logger" -) - -func newNvidiaSMIExec(path string, cfg Config, log *logger.Logger) (*nvidiaSMIExec, error) { - return &nvidiaSMIExec{ - binPath: path, - timeout: cfg.Timeout.Duration(), - Logger: log, - }, nil -} - -type nvidiaSMIExec struct { - binPath string - timeout time.Duration - *logger.Logger -} - -func (e *nvidiaSMIExec) queryGPUInfoXML() ([]byte, error) { - ctx, cancel := context.WithTimeout(context.Background(), e.timeout) - defer cancel() - - cmd := exec.CommandContext(ctx, e.binPath, "-q", "-x") - - e.Debugf("executing '%s'", cmd) - bs, err := cmd.Output() - if err != nil { - return nil, fmt.Errorf("error on '%s': %v", cmd, err) - } - - return bs, nil -} - -func (e *nvidiaSMIExec) queryGPUInfoCSV(properties []string) ([]byte, error) { - if len(properties) == 0 { - return nil, errors.New("can not query CSV GPU Info without properties") - } - - ctx, cancel := context.WithTimeout(context.Background(), e.timeout) - defer cancel() - - cmd := exec.CommandContext(ctx, e.binPath, "--query-gpu="+strings.Join(properties, ","), "--format=csv,nounits") - - e.Debugf("executing '%s'", cmd) - - bs, err := cmd.Output() - if err != nil { - return nil, fmt.Errorf("error on '%s': %v", cmd, err) - } - - return bs, nil -} - -func (e *nvidiaSMIExec) queryHelpQueryGPU() ([]byte, error) { - ctx, cancel := context.WithTimeout(context.Background(), e.timeout) - defer cancel() - - cmd := exec.CommandContext(ctx, e.binPath, "--help-query-gpu") - - e.Debugf("executing '%s'", cmd) - bs, err := cmd.Output() - if err != nil { - return nil, fmt.Errorf("error on '%s': %v", cmd, err) - } - - return bs, err -} |