Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Monitoring hardware status with Python and vSphere API calls
from pyVim.connect import SmartConnect, Disconnect
import ssl
s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE
c = SmartConnect(host='vcenter.lab.local', user='root', pwd='Passw0rd')
print('Valid certificate\n')
c = SmartConnect(host='vcenter.lab.local', user='root', pwd='Passw0rd', sslContext=s)
print('Invalid or untrusted certificate\n')
host = c.content.searchIndex.FindByDnsName(None,'esx1.lab.local',False)
health = host.runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo
print('Hostname: ' +
print('Type: ' + host.hardware.systemInfo.model)
print('Getting temperature sensor data...\n')
for i in health:
if i.sensorType == 'temperature':
print( + ' ' + str(temp) + ' ' + i.baseUnits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.