mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2024-11-24 03:13:50 +01:00
Added support for patched pywbem 0.7.0 and new version 0.8.0, handle SSL error exception
This commit is contained in:
parent
8aecf4e7d1
commit
3f97ca6485
@ -216,12 +216,17 @@
|
||||
#@ Author : Andreas Gottwald
|
||||
#@ Reason : Fix NoneType element bug
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20150512
|
||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||
#@ Reason : Added support for patched pywbem 0.7.0 and new version 0.8.0, handle SSL error exception
|
||||
#@---------------------------------------------------
|
||||
|
||||
import sys
|
||||
import time
|
||||
import pywbem
|
||||
import re
|
||||
import string
|
||||
import pkg_resources
|
||||
from optparse import OptionParser,OptionGroup
|
||||
|
||||
version = '20150119'
|
||||
@ -569,8 +574,24 @@ if os_platform != "win32":
|
||||
sys.exit(ExitCritical)
|
||||
|
||||
# connection to host
|
||||
verboseoutput("Connection to "+hosturl)
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS)
|
||||
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
|
||||
pywbemversion = pkg_resources.get_distribution("pywbem").version
|
||||
if '0.7.0' in pywbemversion:
|
||||
verboseoutput("Found pywbem version "+pywbemversion)
|
||||
verboseoutput("Connection to "+hosturl)
|
||||
try:
|
||||
conntest = pywbem.WBEMConnection(hosturl, (user,password), NS)
|
||||
c=wbemclient.EnumerateInstances('CIM_Card')
|
||||
except:
|
||||
verboseoutput("Connection error, disable SSL certification verification (probably newer pywbem version)")
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
|
||||
else:
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS)
|
||||
# pywbem 0.8.0 and later
|
||||
elif '0.8.0' in pywbemversion:
|
||||
verboseoutput("Found pywbem version "+pywbemversion)
|
||||
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.
|
||||
if on_windows == False and timeout > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user