Created
September 5, 2023 20:34
-
-
Save jpsutton/8734ce209f7874d5e386d2865c1adc8a to your computer and use it in GitHub Desktop.
Reading an Nvidia GPU temperature value from a libvirt Windows guest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GUEST_NAME=Win10_With_GPU | |
job_exited="false" | |
exec_result=$(virsh -c qemu:///system qemu-agent-command "$GUEST_NAME" '{"execute": "guest-exec", "arguments": { "path": "nvidia-smi.exe", "arg": [ "--format=csv,noheader", "--query-gpu=temperature.gpu" ], "capture-output": true }}') | |
exec_pid=$(echo "$exec_result" | jq ".return.pid") | |
while [ "$job_exited" == "false" ]; do | |
exec_job_data=$(virsh -c qemu:///system qemu-agent-command "$GUEST_NAME" '{"execute": "guest-exec-status", "arguments": { "pid": '" ${exec_pid}}}") | |
job_exited=$(echo "$exec_job_data" | jq '.return.exited') | |
if [ "$job_exited" == "false" ]; then | |
sleep .1s | |
continue | |
fi | |
echo "$exec_job_data" | jq '.return["out-data"]' | tr -d '"' | base64 --decode | |
break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's the thought that counts.