vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
746 stars 313 forks source link

How to get power consumption of VMHost? #344

Closed JanLucasK closed 1 year ago

JanLucasK commented 1 year ago

Is your feature request related to a problem? Please describe.

Hello, I would be very grateful for help with my problem.

I would like to query the energy consumption of my VMHosts, however I cannot find such a value/property. The closest I have come to are the values of various sensors via the Property Collector and 'runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo'. These values with the sensorType='power' added together make sense, but are not updated at the interval that power consumption is in vSphere. In vSphere the power consumption is shown every 20 seconds and the timestamps of the sensors (with this API) are hours old. Is there an easier way or is it even possible with this API?

Thanks in advance

Describe the solution you'd like

I would like to query the current power consumption of my VMHosts.

Describe alternatives you've considered

No response

Additional context

No response

mtsvetanov commented 1 year ago

You might be interested in the vStats APIs which are covered by this SDK. I believe power consumption is available there, but you would have to check what counters are actually supported.

JanLucasK commented 1 year ago

That sounds promising, thank you very much :)

karaatanassov commented 1 year ago

You can use govmomi, pyvmomi, the Management SDK or PowerCli and inquire power consumption through the PerformanceManager

See https://vdc-repo.vmware.com/vmwb-repository/dcr-public/1ef6c336-7bef-477d-b9bb-caa1767d7e30/82521f49-9d9a-42b7-b19b-9e6cd9b30db1/vim.PerformanceManager.html