I am trying to get some information from a few ESXi Servers through Python. I found pyvmomi(https://github.com/vmware/pyvmomi) which is a great and easy to understand tool for this purpose. However, I cannot seem to find a way to get "real-time" info on the CPU/RAM/Storage usage. I am going through the SDK of VMware (http://pubs.vmware.com/vsphere-55/topic/com.vmware.sdk.doc/GUID-19793BCA-9EAB-42E2-8B9F-F9F2129E7741.html) but I can only find how many cpus or how much memory the host has.
Has anyone ever done this through Python?
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.