Monitor: show GPU temperature and fan speed
Extends the existing per-tick nvidia-smi query with temperature.gpu and fan.speed (no extra call); N/A values (cards without fan telemetry) are simply omitted from the GPU line.
This commit is contained in:
@@ -116,6 +116,31 @@ func TestParseGPUEngineInstance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGPUStats(t *testing.T) {
|
||||
st, err := parseGPUStats("4300, 16384, 55, 42\n")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.UsedMB != 4300 || st.TotalMB != 16384 || st.TempC != 55 || st.FanPct != 42 {
|
||||
t.Errorf("got %+v", st)
|
||||
}
|
||||
|
||||
// Cards that don't expose temperature/fan report N/A.
|
||||
st, err = parseGPUStats("1024, 16384, N/A, N/A")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.TempC != -1 || st.FanPct != -1 {
|
||||
t.Errorf("got %+v, want -1 for N/A fields", st)
|
||||
}
|
||||
|
||||
for _, bad := range []string{"", "1, 2", "x, 16384, 55, 42", "1024, x, 55, 42", "1, 2, 3, 4, 5"} {
|
||||
if _, err := parseGPUStats(bad); err == nil {
|
||||
t.Errorf("%q parsed, want failure", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessesLive(t *testing.T) {
|
||||
if runtime.GOOS != "windows" && runtime.GOOS != "linux" {
|
||||
t.Skip("no process listing on this platform")
|
||||
|
||||
Reference in New Issue
Block a user