Monitoring hardware status with Python and vSphere API calls

This posting is ~4 years years old. You should keep this in mind. IT is a short living business. This information might be outdated.

Apparently it’s “how to monitor hardware status” week on Some days ago, I wrote an article about using SNMP for hardware monitoring. You can also use the vSphere Web Client to get the status of the host hardware. A third way is through the vSphere API. I just want to share a short example how to use vSphere API calls and pyVmomi. pyVmomi is the Python SDK for the VMware vSphere API.

Get hardware status with vSphere API calls

I just want to share a small example, that shows the basic principle. The script gathers the temperature sensor data of a ProLiant DL360 G7 running ESXi 6.0 U2 using vSphere API calls.

The output of the script looks like this:

Nothing fancy. You can easily loop through numericSensorInfo to gather data from other sensors. Use the Managed Object Browser (MOB) to navigate through the API. This is handy if you search for specific sensors. If you need accurate data, the vSphere API is the way to go. If you focus on something lightweight, try SNMP.

Patrick Terlisten
Follow me

4 thoughts on “Monitoring hardware status with Python and vSphere API calls

  1. Jon Forrest

    I need to find a way to get all the ESXi hosts in a vCenter, and then, for each hosts, check to see if they have a Fibre Channel HBA, and then, if they do, see some information about the Fibre Channel connections.

    Your example gets information about a specific host (e.g. esx1.lab.local). Can you give me some idea of how to get the list of hosts from the Python API?


  2. ale

    I got the error ‘NoneType’ object has no attribute ‘runtime’ running this code;
    Thats becouse host is none type, i don’t know why, can you please help me?


Leave a Reply to Patrick Terlisten Cancel reply

Your email address will not be published. Required fields are marked *