Description:To monitor and maintain infrastructure, it is critical to know if the qemu-guest-agent is up to date. Currently, retrieving the agent version requires executing custom shell commands inside the guest (like dpkg-query, rpm, or registry lookups via exec), which is inefficient and varies by OS.
Proposed Change:Standardize the retrieval of the agent version by adding a version field to the nodes/{node}/qemu/{vmid}/agent/info or status endpoint.The QEMU Guest Agent protocol already supports internal version reporting; exposing this directly in the Proxmox API would be a significant improvement.
Benefit:This would allow for easy auditing of the guest agent versions across the entire cluster via a single API call, facilitating security compliance and troubleshooting of agent-related features (like FS-freeze or network-get-interfaces).
#My script with cmd / powershell core
try {
if ($osinfo -match "Ubuntu|Debian") {
$oslinuxorwindow = "linux"
$versionCmd = 'dpkg-query -W -f=''${Version}'' qemu-guest-agent'
}elseif ($osinfo -match "Red Hat|CentOS|AlmaLinux|Rocky|Fedora") {
$oslinuxorwindow = "linux"
$versionCmd = "rpm -q --queryformat '%{VERSION}' qemu-guest-agent"
}elseif ($osinfo -match "Win") {
$oslinuxorwindow = "windows"
$winCmd = 'Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.DisplayName -match "Virtio-win-guest-tools" } | Select-Object -ExpandProperty DisplayVersion'
}
if ( $oslinuxorwindow -eq "linux") {
$encodedCmd = [Uri]::EscapeDataString($versionCmd)
$body = "command=/bin/sh&command=-c&command=$encodedCmd"
$execRun = Invoke-RestMethod -Uri "https://$server/api2/json/nodes/$node/qemu/$vmid/agent/exec" `
-Headers $headers -Method POST -Body $body `
-ContentType "application/x-www-form-urlencoded" -SkipCertificateCheck
# Pause pour laisser le temps à l'agent de répondre
Start-Sleep -Milliseconds 800
$statusUri = "https://$server/api2/json/nodes/$node/qemu/$vmid/agent/exec-status?pid=$($execRun.data.pid)"
$status = Invoke-RestMethod -Uri $statusUri -Headers $headers -Method GET -SkipCertificateCheck
$qemu_agentversion = $status.data.'out-data'.Trim()
}
if ( $oslinuxorwindow -eq "windows") {
# On construit le body (format x-www-form-urlencoded)
$body = "command=powershell&command=-Command&command=$winCmd"
# Envoi
$execRun = Invoke-RestMethod -Uri "$ProxmoxServer/api2/json/nodes/$node/qemu/$vmid/agent/exec" `
-Headers $headers -Method POST -Body $body `
-ContentType "application/x-www-form-urlencoded" -SkipCertificateCheck
$pidpve = $execRun.data.pid
# On attend un tout petit peu que Windows traite la demande
Start-Sleep -Milliseconds 800
# On interroge le statut du PID
$statusUri = "$ProxmoxServer/api2/json/nodes/$node/qemu/$vmid/agent/exec-status?pid=$pidpve"
$status = Invoke-RestMethod -Uri $statusUri -Headers $headers -Method GET -SkipCertificateCheck
$qemu_agentversion = $status.data.'out-data'.Trim()
}
}catch { }
Proposed Change:Standardize the retrieval of the agent version by adding a version field to the nodes/{node}/qemu/{vmid}/agent/info or status endpoint.The QEMU Guest Agent protocol already supports internal version reporting; exposing this directly in the Proxmox API would be a significant improvement.
Benefit:This would allow for easy auditing of the guest agent versions across the entire cluster via a single API call, facilitating security compliance and troubleshooting of agent-related features (like FS-freeze or network-get-interfaces).
#My script with cmd / powershell core
try {
if ($osinfo -match "Ubuntu|Debian") {
$oslinuxorwindow = "linux"
$versionCmd = 'dpkg-query -W -f=''${Version}'' qemu-guest-agent'
}elseif ($osinfo -match "Red Hat|CentOS|AlmaLinux|Rocky|Fedora") {
$oslinuxorwindow = "linux"
$versionCmd = "rpm -q --queryformat '%{VERSION}' qemu-guest-agent"
}elseif ($osinfo -match "Win") {
$oslinuxorwindow = "windows"
$winCmd = 'Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.DisplayName -match "Virtio-win-guest-tools" } | Select-Object -ExpandProperty DisplayVersion'
}
if ( $oslinuxorwindow -eq "linux") {
$encodedCmd = [Uri]::EscapeDataString($versionCmd)
$body = "command=/bin/sh&command=-c&command=$encodedCmd"
$execRun = Invoke-RestMethod -Uri "https://$server/api2/json/nodes/$node/qemu/$vmid/agent/exec" `
-Headers $headers -Method POST -Body $body `
-ContentType "application/x-www-form-urlencoded" -SkipCertificateCheck
# Pause pour laisser le temps à l'agent de répondre
Start-Sleep -Milliseconds 800
$statusUri = "https://$server/api2/json/nodes/$node/qemu/$vmid/agent/exec-status?pid=$($execRun.data.pid)"
$status = Invoke-RestMethod -Uri $statusUri -Headers $headers -Method GET -SkipCertificateCheck
$qemu_agentversion = $status.data.'out-data'.Trim()
}
if ( $oslinuxorwindow -eq "windows") {
# On construit le body (format x-www-form-urlencoded)
$body = "command=powershell&command=-Command&command=$winCmd"
# Envoi
$execRun = Invoke-RestMethod -Uri "$ProxmoxServer/api2/json/nodes/$node/qemu/$vmid/agent/exec" `
-Headers $headers -Method POST -Body $body `
-ContentType "application/x-www-form-urlencoded" -SkipCertificateCheck
$pidpve = $execRun.data.pid
# On attend un tout petit peu que Windows traite la demande
Start-Sleep -Milliseconds 800
# On interroge le statut du PID
$statusUri = "$ProxmoxServer/api2/json/nodes/$node/qemu/$vmid/agent/exec-status?pid=$pidpve"
$status = Invoke-RestMethod -Uri $statusUri -Headers $headers -Method GET -SkipCertificateCheck
$qemu_agentversion = $status.data.'out-data'.Trim()
}
}catch { }