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/collect.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/collect.go | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/nvidia_smi/collect.go b/src/go/collectors/go.d.plugin/modules/nvidia_smi/collect.go deleted file mode 100644 index 0830b54a3..000000000 --- a/src/go/collectors/go.d.plugin/modules/nvidia_smi/collect.go +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -package nvidia_smi - -import ( - "errors" - "strconv" - "strings" -) - -func (nv *NvidiaSMI) collect() (map[string]int64, error) { - if nv.exec == nil { - return nil, errors.New("nvidia-smi exec is not initialized") - } - - mx := make(map[string]int64) - - if err := nv.collectGPUInfo(mx); err != nil { - return nil, err - } - - return mx, nil -} - -func (nv *NvidiaSMI) collectGPUInfo(mx map[string]int64) error { - if nv.UseCSVFormat { - return nv.collectGPUInfoCSV(mx) - } - return nv.collectGPUInfoXML(mx) -} - -func addMetric(mx map[string]int64, key, value string, mul int) { - if !isValidValue(value) { - return - } - - value = removeUnits(value) - - v, err := strconv.ParseFloat(value, 64) - if err != nil { - return - } - - if mul > 0 { - v *= float64(mul) - } - - mx[key] = int64(v) -} - -func isValidValue(v string) bool { - return v != "" && v != "N/A" && v != "[N/A]" -} - -func parseFloat(s string) float64 { - v, _ := strconv.ParseFloat(removeUnits(s), 64) - return v -} - -func removeUnits(s string) string { - if i := strings.IndexByte(s, ' '); i != -1 { - s = s[:i] - } - return s -} - -func boolToInt(v bool) int64 { - if v { - return 1 - } - return 0 -} |