4👍
Check the pyvmomi-community-samples. There’s a python script in there called esxi_perf_sample.py with an example on how to retrieve a specific metric in a specified period of time.
Along with that example, check this implementation.
The trick here resides on the counterId mapping into human-readable names of the available metrics that are currently implemented on the target machine. You should first retrieve the available counters before you attempt to retrieve their values.
In my opinion, the implementation of the second link of this post is one of the best public examples that you’ll find based on pyVmomi at the time of this writing. Take a careful look into it as it will probably answer all your doubts for itself.
Also note that although the Geeklee vminfo implementation is Guest oriented, all the metrics are still valid for the Host. You just need to adapt the script to specify the Host entity instead of the Guest (or allow both) when you perform the query.
Finally, the "real-time" granularity for the retrieved metrics can be specified by a time interval when performing the query call. You should specify an interval based on your needs, but note that for the latest vSphere versions, the minimum (default) interval between samples is 20 seconds, so you should not specify a time interval lesser than this value.
3👍
I have added script to extract cpu usage of esxhosts with multithreading. You can find it on my github
https://github.com/dograga/ESXPerfData
- [Django]-“select_for_update” called inside an atomic block still TransactionManagementError
- [Django]-In Django, is there an easy way to render a text field as a template, in a template?