Python: Use hpilo to query iLO ambient temperature sensor, i.e. use HP sensors for ghetto datacenter temperature monitoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hpilo | |
tempkey = { | |
2 : 'Temp 1', | |
3 : 'Temp 1', | |
4 : '01-Inlet Ambient' | |
} | |
def get_ambient_temp(host, username, password, ilo_version): | |
try: | |
# Specifying the protocol saves a query to the iLO | |
if ilo_version <= 2: | |
proto = hpilo.ILO_RAW | |
else: | |
proto = hpilo.ILO_HTTP | |
ilo = hpilo.Ilo(host, username, password, protocol=proto) | |
health = ilo.get_embedded_health() | |
celsius = health['temperature'][tempkey[ilo_version]]['currentreading'][0] | |
return celsius | |
except hpilo.IloError: | |
return None | |
def CtoF(cel): | |
"Convert Celsius to Fahrenheit" | |
return '%.2f' % (cel * 1.8 +32) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment