Proxmox api "Resources"

Kosh

Well-Known Member
Dec 24, 2019
83
6
48
45
Hi!
in the web there is a display of the summed resources of the cluster

1737623444508.png


I studied the api documentation and did not find the final entry point to this data, maybe I was looking badly?
I am interested in exactly the data that is on the screenshot
I know how to get them with a script, but it will be complicated and will have to go through each node of the cluster, but here everything is already ready, how can I get this data with a request?
 
It's the /cluster/resources API endpoint :)

It returns an array of all resources of your cluster - nodes, guests, storages, etc.

Hope this helps!
 
It's the /cluster/resources API endpoint :)

It returns an array of all resources of your cluster - nodes, guests, storages, etc.

Hope this helps!
everything is more complicated ))
I never delved into it, but this bar above summed up ALL datastores including datastores from pbs, and I needed datastores for vm
as a result, the requests look like this

full volume of local datastores (lvm-thin and zfspool)

Code:
storage=$(pvesh get /cluster/resources -type storage --output-format json |jq '.[] | select(.plugintype == "zfspool" or .plugintype == "lvmthin") | {maxdisk} | add' |awk '{sum += $1} END {print sum}')

#Convert a number from scientific to normal format
storage_byte_format=$(printf "%.f\n" "$storage")

#Converting from bytes to TB
storage_tb=$(numfmt --to=iec $storage_byte_format)

echo $storage_tb


Actual consumed size of allocated vm disks on local datastores

Code:
storage_used=$(pvesh get /cluster/resources -type storage --output-format json |jq '.[] | select(.plugintype == "zfspool" or .plugintype == "lvmthin") | {disk} | add' |awk '{sum += $1} END {print sum}')

#Convert a number from scientific to normal format
storage_used_byte_format=$(printf "%.f\n" "$storage_used")

#Converting from bytes to TB
storage_used_tb=$(numfmt --to=iec $storage_used_byte_format)
echo $storage_used_tb


it might be useful to someone
 
  • Like
Reactions: UdoB