1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2024-10-22 12:13:46 +02:00

Extended pywbem version compatibility

This commit is contained in:
Napsty 2015-06-10 12:47:12 +02:00
parent 3f97ca6485
commit 6c8a4bfd63

View File

@ -574,25 +574,25 @@ if os_platform != "win32":
sys.exit(ExitCritical) sys.exit(ExitCritical)
# connection to host # connection to host
verboseoutput("Connection to "+hosturl)
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently # pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
pywbemversion = pkg_resources.get_distribution("pywbem").version pywbemversion = pkg_resources.get_distribution("pywbem").version
verboseoutput("Found pywbem version "+pywbemversion)
if '0.7.0' in pywbemversion: if '0.7.0' in pywbemversion:
verboseoutput("Found pywbem version "+pywbemversion)
verboseoutput("Connection to "+hosturl)
try: try:
conntest = pywbem.WBEMConnection(hosturl, (user,password), NS) conntest = pywbem.WBEMConnection(hosturl, (user,password))
c=wbemclient.EnumerateInstances('CIM_Card') c = conntest.EnumerateInstances('CIM_Card')
except: except:
verboseoutput("Connection error, disable SSL certification verification (probably newer pywbem version)") #raise
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True) verboseoutput("Connection error, disable SSL certification verification (probably patched pywbem)")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), no_verification=True)
else: else:
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS) verboseoutput("Connection worked")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
# pywbem 0.8.0 and later # pywbem 0.8.0 and later
elif '0.8.0' in pywbemversion: elif '0.8.0' in pywbemversion:
verboseoutput("Found pywbem version "+pywbemversion)
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True) wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout. # Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
if on_windows == False and timeout > 0: if on_windows == False and timeout > 0:
signal.signal(signal.SIGALRM, handler) signal.signal(signal.SIGALRM, handler)
@ -655,7 +655,7 @@ for classe in ClassesToCheck :
sensor_value = "" sensor_value = ""
elementName = instance['ElementName'] elementName = instance['ElementName']
if elementName is None : if elementName is None :
elementName = 'Unknown' elementName = 'Unknown'
elementNameValue = elementName elementNameValue = elementName
verboseoutput(" Element Name = "+elementName) verboseoutput(" Element Name = "+elementName)
@ -798,8 +798,8 @@ for classe in ClassesToCheck :
# Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it # Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it
ignore_list.append("System Board 1 Riser Config Err 0: Connected") ignore_list.append("System Board 1 Riser Config Err 0: Connected")
ignore_list.append("System Board 1 LCD Cable Pres 0: Connected") ignore_list.append("System Board 1 LCD Cable Pres 0: Connected")
ignore_list.append("System Board 1 VGA Cable Pres 0: Connected") ignore_list.append("System Board 1 VGA Cable Pres 0: Connected")
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected") ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
if instance['OperationalStatus'] is not None : if instance['OperationalStatus'] is not None :
elementStatus = instance['OperationalStatus'][0] elementStatus = instance['OperationalStatus'][0]
verboseoutput(" Element Op Status = %d" % elementStatus) verboseoutput(" Element Op Status = %d" % elementStatus)
@ -884,3 +884,4 @@ else:
print "%s- Server: %s %s %s%s" % (ExitMsg, server_info, SerialNumber, bios_info, perf) print "%s- Server: %s %s %s%s" % (ExitMsg, server_info, SerialNumber, bios_info, perf)
sys.exit (GlobalStatus) sys.exit (GlobalStatus)