Skip to content

Commit

Permalink
Add DriverVersion and CUDA Version to output (influxdata#8436)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuzyashin authored Nov 19, 2020
1 parent 5595d4a commit 170693d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugins/inputs/nvidia_smi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ You'll need to escape the `\` within the `telegraf.conf` like this: `C:\\Program
- `clocks_current_sm` (integer, MHz)
- `clocks_current_memory` (integer, MHz)
- `clocks_current_video` (integer, MHz)
- `driver_version` (string)
- `cuda_version` (string)

### Sample Query

Expand Down
10 changes: 9 additions & 1 deletion plugins/inputs/nvidia_smi/nvidia_smi.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func (s *SMI) genTagsFields() []metric {
setTagIfUsed(tags, "uuid", gpu.UUID)
setTagIfUsed(tags, "compute_mode", gpu.ComputeMode)

setIfUsed("str", fields, "driver_version", s.DriverVersion)
setIfUsed("str", fields, "cuda_version", s.CUDAVersion)
setIfUsed("int", fields, "fan_speed", gpu.FanSpeed)
setIfUsed("int", fields, "memory_total", gpu.Memory.Total)
setIfUsed("int", fields, "memory_used", gpu.Memory.Used)
Expand Down Expand Up @@ -169,12 +171,18 @@ func setIfUsed(t string, m map[string]interface{}, k, v string) {
m[k] = i
}
}
case "str":
if val != "" {
m[k] = val
}
}
}

// SMI defines the structure for the output of _nvidia-smi -q -x_.
type SMI struct {
GPU GPU `xml:"gpu"`
GPU GPU `xml:"gpu"`
DriverVersion string `xml:"driver_version"`
CUDAVersion string `xml:"cuda_version"`
}

// GPU defines the structure of the GPU portion of the smi output.
Expand Down
4 changes: 4 additions & 0 deletions plugins/inputs/nvidia_smi/nvidia_smi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func TestGatherValidXML(t *testing.T) {
"clocks_current_memory": 405,
"clocks_current_sm": 300,
"clocks_current_video": 540,
"cuda_version": "10.1",
"driver_version": "418.43",
"encoder_stats_average_fps": 0,
"encoder_stats_average_latency": 0,
"encoder_stats_session_count": 0,
Expand Down Expand Up @@ -109,6 +111,8 @@ func TestGatherValidXML(t *testing.T) {
"clocks_current_memory": 405,
"clocks_current_sm": 139,
"clocks_current_video": 544,
"cuda_version": "10.1",
"driver_version": "418.43",
"encoder_stats_average_fps": 0,
"encoder_stats_average_latency": 0,
"encoder_stats_session_count": 0,
Expand Down

0 comments on commit 170693d

Please sign in to comment.