Export List of All VM Proxmox

Hi,

the text output does not show the (for me necessary) columns "name", but it's present in the json output. Any idea how the vm name can be shown in the human readable output?
 
Technically you could get metrics through GRAPHITE or InfluxDB but I agree, updating spreadsheets containing current VM configurations and resource allocations in the GUI would be exceptional for automating our documentation work.

+1 for this feature. Thanks Hannes!


Tmanok
 
Assuming you put your json output in a file called vm.json; you can convert that to csv:

pvesh get /cluster/resources --type vm --output-format json > vm.json

then do something like this:

jq -r '.[] | [.vmid, .name, .status] | @csv' "vm.json" |tr -d '"'
 
  • Like
Reactions: Kingneutron
Hi Ramon,

That's a good example, for me I'd like to make sure IP's are correctly configured and following IPAM in environments with multiple staff and many VMs. Moreover, I wish to document the current configuration of all the VMs in an easy to read and compare table, enabling easy CPU and Memory resource allocation calculations, etc. Maybe others have completely different ambitions, so a broad-spectrum output that anyone can narrow down from would look like:
Code:
pvesh get /cluster/resources --output-format json-pretty > clusterresources.json
jq -r '.[] | [.cpu, .content, .disk, .diskread, .diskwrite, .id, .maxcpu, .maxdisk, .maxmem, .mem, .name, .netin, .netout, .node, .plugintype, .pool, .sdn, .shared, .status, .tags, .template, .type, .uptime, .vmid] | @csv' "clusterresources.json" |tr -d '"' > clusterresources.csv

Mind you, depending on your CSV interpreter (e.g. LibreOffice) I noticed that the CSV file from the above export is not opened correctly due to the blank columns for some of the data. Anyway, this will provide other readers with the "complete" set of options, from which they can whittle down to their preference.

For IP addresses in particular, it is far too specific to extract from all VMs and unfortunately is specific to the interface and the parsing of the qemu-agent data:
pvesh get /nodes/pve2/qemu/120/agent/network-get-interfaces -o json | jq '.result[] | select(.name == "ens18") | .["ip-addresses"][] | select(.["ip-address-type"] == "ipv4") | .["ip-address"]'
Which will yield a single IP address.

Ideally, there should be a GUI feature that harmonizes the outputs of PVESH into a more massaged and simple to data dump file. It would save many hours comparing configurations, troubleshooting, resource planning, and maintaining large clusters with hundreds of VMs and their oddly specific networking. Firewall exports would also be helpful en-masse.

Thanks,


Tmanok
 
It would be lovely if it were possible to do the same for all guests tracked in PDM. I manage an environment with 64 remotes and just over 400 VMs. Being able to export the data on the entire network at once would be quite convenient.
 
It would be lovely if it were possible to do the same for all guests tracked in PDM. I manage an environment with 64 remotes and just over 400 VMs. Being able to export the data on the entire network at once would be quite convenient.
Check also yet another API consumer:

https://github.com/ciroiriarte/pve-cli

Would be nice to hear from feedback at your scale. VM count sounds a little low for 64 clusters though
 
Check also yet another API consumer:

https://github.com/ciroiriarte/pve-cli

Would be nice to hear from feedback at your scale. VM count sounds a little low for 64 clusters though
I can look into implementing one or both of these at some point, I work in a rather busy production environment. We're still growing and implementing new services and security controls every day.

Five of those servers are in a cluster, the rest are all individual nodes. They're hosted in small groups globally and use their own on board storage, so we haven't clustered them. We're also steadily transitioning from ESXI to Proxmox, so we're up to 67 nodes now.