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

Merge pull request #1 from Napsty/dev

Authentication error timeout improvement
This commit is contained in:
Napsty 2013-07-11 05:31:28 -07:00
commit dddaab0f3b

25
check_esxi_hardware.py Normal file → Executable file
View File

@ -34,6 +34,7 @@
# Copyright (c) 2011 Bertrand Jomin
# Copyright (c) 2011 Ian Chard
# Copyright (c) 2012 Craig Hart
# Copyright (c) 2013 Carl R. Friend
#
# 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
@ -194,6 +195,10 @@
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ 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 time
@ -202,7 +207,7 @@ import re
import string
from optparse import OptionParser,OptionGroup
version = '20130424'
version = '20130702'
NS = 'root/cimv2'
@ -535,7 +540,20 @@ ExitMsg = ""
# if vendor is specified as 'auto', try to get vendor from CIM
# note: the default vendor is 'unknown'
if vendor=='auto':
try:
c=wbemclient.EnumerateInstances('CIM_Chassis')
except pywbem.cim_operations.CIMError,args:
if ( args[1].find('Socket error') >= 0 ):
print "UNKNOWN: %s" %args
sys.exit (ExitUnknown)
else:
verboseoutput("Unknown CIM Error: %s" % args)
except pywbem.cim_http.AuthError,arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else:
man=c[0][u'Manufacturer']
if re.match("Dell",man):
vendor="dell"
@ -559,9 +577,10 @@ for classe in ClassesToCheck :
else:
verboseoutput("Unknown CIM Error: %s" % args)
except pywbem.cim_http.AuthError,arg:
verboseoutput("Global exit set to CRITICAL")
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitCritical
ExitMsg = " : Authentication Error! "
print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else:
# GlobalStatus = ExitOK #ARR
for instance in instance_list :