1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2024-10-22 20:23:45 +02:00

Authentication error timeout improvment

This commit is contained in:
Napsty 2013-07-02 16:11:14 +02:00
parent a655031283
commit e0aac56005

45
check_esxi_hardware.py Normal file → Executable file
View File

@ -34,6 +34,7 @@
# Copyright (c) 2011 Bertrand Jomin # Copyright (c) 2011 Bertrand Jomin
# Copyright (c) 2011 Ian Chard # Copyright (c) 2011 Ian Chard
# Copyright (c) 2012 Craig Hart # Copyright (c) 2012 Craig Hart
# Copyright (c) 2013 Carl R. Friend
# #
# The VMware 4.1 CIM API is documented here: # The VMware 4.1 CIM API is documented here:
# http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf # http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf
@ -194,6 +195,10 @@
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com) #@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Another workaround for Dell systems "System Board 1 LCD Cable Pres 0: Connected" #@ Reason : Another workaround for Dell systems "System Board 1 LCD Cable Pres 0: Connected"
#@--------------------------------------------------- #@---------------------------------------------------
#@ Date : 20130702
#@ Author : Carl R. Friend
#@ Reason : Improving wrong authentication timeout and exit UNKNOWN
#@---------------------------------------------------
import sys import sys
import time import time
@ -535,18 +540,31 @@ ExitMsg = ""
# if vendor is specified as 'auto', try to get vendor from CIM # if vendor is specified as 'auto', try to get vendor from CIM
# note: the default vendor is 'unknown' # note: the default vendor is 'unknown'
if vendor=='auto': if vendor=='auto':
c=wbemclient.EnumerateInstances('CIM_Chassis') try:
man=c[0][u'Manufacturer'] c=wbemclient.EnumerateInstances('CIM_Chassis')
if re.match("Dell",man): except pywbem.cim_operations.CIMError,args:
vendor="dell" if ( args[1].find('Socket error') >= 0 ):
elif re.match("HP",man): print "UNKNOWN: %s" %args
vendor="hp" sys.exit (ExitUnknown)
elif re.match("IBM",man): else:
vendor="ibm" verboseoutput("Unknown CIM Error: %s" % args)
elif re.match("Intel",man): except pywbem.cim_http.AuthError,arg:
vendor="intel" verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else: else:
vendor='unknown' man=c[0][u'Manufacturer']
if re.match("Dell",man):
vendor="dell"
elif re.match("HP",man):
vendor="hp"
elif re.match("IBM",man):
vendor="ibm"
elif re.match("Intel",man):
vendor="intel"
else:
vendor='unknown'
for classe in ClassesToCheck : for classe in ClassesToCheck :
verboseoutput("Check classe "+classe) verboseoutput("Check classe "+classe)
@ -559,9 +577,10 @@ for classe in ClassesToCheck :
else: else:
verboseoutput("Unknown CIM Error: %s" % args) verboseoutput("Unknown CIM Error: %s" % args)
except pywbem.cim_http.AuthError,arg: except pywbem.cim_http.AuthError,arg:
verboseoutput("Global exit set to CRITICAL") verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitCritical GlobalStatus = ExitCritical
ExitMsg = " : Authentication Error! " print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else: else:
# GlobalStatus = ExitOK #ARR # GlobalStatus = ExitOK #ARR
for instance in instance_list : for instance in instance_list :