summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2024-06-14 08:53:19 +0300
committerGitHub <noreply@github.com>2024-06-14 08:53:19 +0300
commit8575cb5ba10d8745469acf2b8bb0616f3fe7bdb1 (patch)
tree83d3e7f349b822666ed0685b4541ca7a883df902 /src
parent606ebbfc8c91c7ced89dd2b20a37a623b4cf1f42 (diff)
go.d intelgpu add an option to select specific GPU (#17884)
go.d intel_gpu_top add an option to select specific GPU
Diffstat (limited to 'src')
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/config_schema.json8
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/exec.go19
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/init.go2
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go3
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/metadata.yaml4
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.json3
-rw-r--r--src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.yaml1
7 files changed, 30 insertions, 10 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/config_schema.json b/src/go/collectors/go.d.plugin/modules/intelgpu/config_schema.json
index ddee75e7af..ac81834218 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/config_schema.json
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/config_schema.json
@@ -10,6 +10,11 @@
"type": "integer",
"minimum": 1,
"default": 1
+ },
+ "device": {
+ "title": "Device selector",
+ "description": "Select Intel GPU ([supported filters](https://manpages.debian.org/testing/intel-gpu-tools/intel_gpu_top.1.en.html#DEVICE_SELECTION)). Use `intel_gpu_top -L` for listing devices. If not set, defaults to first.",
+ "type": "string"
}
},
"additionalProperties": false,
@@ -20,6 +25,9 @@
"uiSchema": {
"uiOptions": {
"fullPage": true
+ },
+ "device": {
+ "ui:placeholder": "For systems with multiple GPUs, create separate data collection jobs and specify the device for each job."
}
}
}
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/exec.go b/src/go/collectors/go.d.plugin/modules/intelgpu/exec.go
index d4a62b2a79..8a57c798ba 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/exec.go
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/exec.go
@@ -14,11 +14,12 @@ import (
"github.com/netdata/netdata/go/go.d.plugin/logger"
)
-func newIntelGpuTopExec(ndsudoPath string, updateEvery int, log *logger.Logger) (*intelGpuTopExec, error) {
+func newIntelGpuTopExec(log *logger.Logger, ndsudoPath string, updateEvery int, device string) (*intelGpuTopExec, error) {
topExec := &intelGpuTopExec{
Logger: log,
ndsudoPath: ndsudoPath,
updateEvery: updateEvery,
+ device: device,
firstSampleTimeout: time.Second * 3,
}
@@ -34,6 +35,7 @@ type intelGpuTopExec struct {
ndsudoPath string
updateEvery int
+ device string
firstSampleTimeout time.Duration
cmd *exec.Cmd
@@ -44,7 +46,13 @@ type intelGpuTopExec struct {
}
func (e *intelGpuTopExec) run() error {
- cmd := exec.Command(e.ndsudoPath, "igt-json", "--interval", e.calcIntervalArg())
+ var cmd *exec.Cmd
+
+ if e.device != "" {
+ cmd = exec.Command(e.ndsudoPath, "igt-device-json", "--interval", e.calcIntervalArg(), "--device", e.device)
+ } else {
+ cmd = exec.Command(e.ndsudoPath, "igt-json", "--interval", e.calcIntervalArg())
+ }
e.Debugf("executing '%s'", cmd)
@@ -146,11 +154,8 @@ func (e *intelGpuTopExec) stop() error {
func (e *intelGpuTopExec) calcIntervalArg() string {
// intel_gpu_top appends the end marker ("},\n") of the previous sample to the beginning of the next sample.
// interval must be < than 'firstSampleTimeout'
- var interval int
- m := min(e.updateEvery, int(e.firstSampleTimeout.Seconds()))
- if m <= 1 {
- interval = 900
- } else {
+ interval := 900
+ if m := min(e.updateEvery, int(e.firstSampleTimeout.Seconds())); m > 1 {
interval = m*1000 - 500 // milliseconds
}
return strconv.Itoa(interval)
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/init.go b/src/go/collectors/go.d.plugin/modules/intelgpu/init.go
index e36db7c163..5b02d02b24 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/init.go
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/init.go
@@ -17,5 +17,5 @@ func (ig *IntelGPU) initIntelGPUTopExec() (intelGpuTop, error) {
}
- return newIntelGpuTopExec(ndsudoPath, ig.UpdateEvery, ig.Logger)
+ return newIntelGpuTopExec(ig.Logger, ndsudoPath, ig.UpdateEvery, ig.Device)
}
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go b/src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go
index a0f34c2e84..d36295c2be 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/intelgpu.go
@@ -29,7 +29,8 @@ func New() *IntelGPU {
}
type Config struct {
- UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
+ UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
+ Device string `yaml:"device,omitempty" json:"device"`
}
type (
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/metadata.yaml b/src/go/collectors/go.d.plugin/modules/intelgpu/metadata.yaml
index 1ff16ed785..3b5b39f25b 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/metadata.yaml
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/metadata.yaml
@@ -60,6 +60,10 @@ modules:
description: Data collection frequency.
default_value: 1
required: false
+ - name: device
+ description: 'Select a specific GPU using [supported filter](https://manpages.debian.org/testing/intel-gpu-tools/intel_gpu_top.1.en.html#DESCRIPTION).'
+ default_value: ""
+ required: false
examples:
folding:
title: Config
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.json b/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.json
index 0e3f7c4039..167bd15fec 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.json
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.json
@@ -1,3 +1,4 @@
{
- "update_every": 123
+ "update_every": 123,
+ "device": "ok"
}
diff --git a/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.yaml b/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.yaml
index f21a3a7a06..f27729e3cb 100644
--- a/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.yaml
+++ b/src/go/collectors/go.d.plugin/modules/intelgpu/testdata/config.yaml
@@ -1 +1,2 @@
update_every: 123
+device: "ok"