Export List of All VM Proxmox

Hey,

pvesh get /cluster/resources --type vm --output-format [text, json, json-pretty, yaml] should be what you're looking for.
 
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
 
  • Like
Reactions: Kingneutron

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!