diff --git a/plugins/inputs/nvidia_smi/README.md b/plugins/inputs/nvidia_smi/README.md index bbe90e005c6d6..f147137f36b77 100644 --- a/plugins/inputs/nvidia_smi/README.md +++ b/plugins/inputs/nvidia_smi/README.md @@ -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 diff --git a/plugins/inputs/nvidia_smi/nvidia_smi.go b/plugins/inputs/nvidia_smi/nvidia_smi.go index 688c3d4bb7680..f1ebfa38babb9 100644 --- a/plugins/inputs/nvidia_smi/nvidia_smi.go +++ b/plugins/inputs/nvidia_smi/nvidia_smi.go @@ -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) @@ -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. diff --git a/plugins/inputs/nvidia_smi/nvidia_smi_test.go b/plugins/inputs/nvidia_smi/nvidia_smi_test.go index 3c191e609ade4..ea5887ae10a5d 100644 --- a/plugins/inputs/nvidia_smi/nvidia_smi_test.go +++ b/plugins/inputs/nvidia_smi/nvidia_smi_test.go @@ -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, @@ -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,