-1

At this moment i am tryging to retrieve the quickstats of an ESXI host itself.

This is the way i connect :

   context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
   context.verify_mode = ssl.CERT_NONE
   si = SmartConnect(host=args.host,
                     user=args.user,
                     pwd=password,
                     port=int(args.port),
                     sslContext=context)

How do i retrieve the following stats with this library? https://github.com/vmware/pyvmomi/blob/master/docs/vim/host/Summary/QuickStats.rst

Dany
  • 735
  • 1
  • 8
  • 27

1 Answers1

0

First you need to locate your host, then access the properties like so:

content = si.RetrieveContent()
host = content.searchIndex.FindByDnsName(dnsName="DC0_C0_H0", vmSearch=False)
print host.summary.quickStats.uptime

The method Im using to locate the host does not have to be used.. its just one of MANY ways of finding a host.. This example assumes you only need to do this for 1 or 2 hosts... Assuming you have lots of hosts and dont want the call to be slow you would really want to build a property collector to fetch that data or else the call will take ages.. If you look at the community samples there is an example or 2 that use views and property collectors which will make your code fast and scaleable.

Michael Rice
  • 7,974
  • 1
  • 15
  • 18
  • where can I find more information on the property collector? By information I mean something other than the, rather drab `official Documentation` by vmware. Something like a blog that explains clearly just _what_ a property collector is and how to use it. – AjB Mar 02 '23 at 10:04