Monitoring hardware status with Python and vSphere API calls

This posting is ~3 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 vcloudnine.de. 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.

Monitoring hardware status with Python and vSphere API calls
4.5 (90%) 8 vote[s]
Follow me

Patrick Terlisten

vcloudnine.de is the personal blog of Patrick Terlisten. Patrick has a strong focus on virtualization & cloud solutions, but also storage, networking, and IT infrastructure in general. He is a fan of Lean Management and agile methods, and practices continuous improvement whereever it is possible.

Feel free to follow him on Twitter and/ or leave a comment.
Patrick Terlisten
Follow me

3 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?

    Thanks.

    Reply

Leave a Reply

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

I accept!