Hypervisor Resource overview using API

Sep 1, 2020
9
3
23
Hi,

I have a problem I hope someone might be able to point me in the correct direction to solve.

My issue:
I want to list out memory used and installed physical memory for each hypervisor in a cluster, using http API call.

When doing a CLI, the result is presented as I want, like:
cli.png
This shows physical memory (maxmem) and used memory (mem) for each hypervisor.

When trying to do the same from the http api call, I would expect to get same output, but only get very partial details compared to CLI, like:
http.png Command used on the bottom line, and two hypervisor example outputs 'snipped in'. Why is the info using http so reduced compared to CLI, or am I missing something to get the same details level using http?
 
Hi, thank you for responding.

How would you format the command to include one of the optional parameters then, like 'maxmem' ? Tried several things whithout getting a working command :)
 
my bad, the optional parameters are return value.

anyways, your code works for me. with your command curl -k -b $ticket -X GET "https://localhost:8006/api2/json/cluster/resources | jq -r '.data[] | select(.type | contains("node"))'" I get the output
Code:
{
  "node": "dev200",
  "cpu": 0.00606196452336456,
  "uptime": 7223,
  "type": "node",
  "mem": 1321598976,
  "maxdisk": 67799756800,
  "status": "online",
  "level": "",
  "disk": 45155565568,
  "maxcpu": 8,
  "id": "node/dev200",
  "maxmem": 16675291136
}
 
Update; problem solved :)

It still only reported 5 of those values when running in our environment, but after some digging I found the cause:

The user used to authenticate towards proxmox was missing one essential privilige: Sys.Audit
Adding this fixed the problem and all values reported as expected.

The doc on https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/resources says:
Required permissions: Accessible by all authenticated users.

Maybe doc should be updated with correct requirements ?

Thank you for your assist!

-Svein-
 

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!