Search code examples
vspherevcenter

Fetching hardware usage info from all ESXi hosts


I've recently got a little bit acquainted with VSphere environment. And I am looking for the way Hardware info can be automatically fetched via all hosts(specified cluster) in Vcenter (maybe with the help of API).

I have found the exact tab where I can get this info, but how can I access through API?

Thanks!


Solution

  • You have plenty of options ranging from pure metrics solutions to hand cranked API calls. I will try and give you a flavor of some.

    TIG Stack (Free)

    This is more on the "pure metrics solutions" end of the spectrum. You setup three services; Telegraf (Data Collector with vSphere Plugin), InfluxDB (Time series database) and Grafana (pretty dashboards).

    CLIs (Free)

    There is a vSphere CLI for Windows, and my personal favorite GOVC (there might be more). GOVC has a range of host info commands, here is an example:

    export GOVC_USERNAME="[email protected]"
    export GOVC_PASSWORD="<PASSOWRD>"
    export GOVC_URL="https://<VCENTER>"
    export GOVC_INSECURE=true
    
    # Regex will needed changing for > 1 host
    export GOVC_HOST=$(govc find / -type h | sed 's:.*/::')
    
    govc host.info
    govc host.service.ls
    govc host.date.info
    govc host.cert.info
    govc host.autostart.info
    govc host.portgroup.info
    govc host.storage.info
    govc host.vnic.info
    govc host.vswitch.info
    govc host.esxcli network ip connection list
    

    The govc host.esxcli command probably offers the most flexibility. And if you want to get into the weeds of esx, esxtop will help.

    SDKs (Free)

    VMware have written a few SDKs for their REST and SOAP API. As far as I can tell their Python (pyvmomi) and Golang (govmomi) have the most active users. Other SDKs can be found here.

    REST (Free)

    If you go to:

    https://<VCENTER>/apiexplorer/index.html
    

    You will find a range of REST endpoints you can try out, some of which are monitoring related. VMware plan on moving a lot of their vCenter SOAP endpoints to REST...eventually.

    VMware Products (Paid)

    There are other paid options available from VMware. The most appropriate choice would be vRealize Operations Manager, following that, vRealize Orchestrator (formerly vCenter Orchestrator) has some REST metrics endpoints exposed based on @Andrew76868's (OP) comment.

    Hope this helps!