mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2026-02-06 15:15:20 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad1e56c44c | ||
|
|
ecfb411b05 | ||
|
|
aaaa2fc1e3 | ||
|
|
0149512f50 | ||
|
|
d03a586ddc | ||
|
|
bdea961ea0 | ||
|
|
676b724b37 | ||
|
|
16a9ce1f36 | ||
|
|
602651d3e5 | ||
|
|
e63f9fee6a |
@@ -22,7 +22,7 @@
|
|||||||
# Copyright (c) 2008 David Ligeret
|
# Copyright (c) 2008 David Ligeret
|
||||||
# Copyright (c) 2009 Joshua Daniel Franklin
|
# Copyright (c) 2009 Joshua Daniel Franklin
|
||||||
# Copyright (c) 2010 Branden Schneider
|
# Copyright (c) 2010 Branden Schneider
|
||||||
# Copyright (c) 2010-2025 Claudio Kuenzler
|
# Copyright (c) 2010-2024 Claudio Kuenzler
|
||||||
# Copyright (c) 2010 Samir Ibradzic
|
# Copyright (c) 2010 Samir Ibradzic
|
||||||
# Copyright (c) 2010 Aaron Rogers
|
# Copyright (c) 2010 Aaron Rogers
|
||||||
# Copyright (c) 2011 Ludovic Hutin
|
# Copyright (c) 2011 Ludovic Hutin
|
||||||
@@ -292,17 +292,12 @@
|
|||||||
#@ Author : Claudio Kuenzler
|
#@ Author : Claudio Kuenzler
|
||||||
#@ Reason : Fix bug when missing S/N (issue #68)
|
#@ Reason : Fix bug when missing S/N (issue #68)
|
||||||
#@---------------------------------------------------
|
#@---------------------------------------------------
|
||||||
#@ Date : 20241129
|
#@ Date : 20241025
|
||||||
#@ Author : Claudio Kuenzler
|
#@ Author : Claudio Kuenzler
|
||||||
#@ Reason : Fix pkg_resources deprecation warning
|
#@ Reason : Fix pkg_resources deprecation warning
|
||||||
# Remove python2 compatibility
|
# Remove python2 compatibility
|
||||||
# Remove pywbem 0.7.0 compatibility
|
# Remove pywbem 0.7.0 compatibility
|
||||||
#@---------------------------------------------------
|
#@---------------------------------------------------
|
||||||
#@ Date : 20250221
|
|
||||||
#@ Author : Claudio Kuenzler
|
|
||||||
#@ Reason : Update to newer pywbem exception call, catch HTTPError
|
|
||||||
#@ Attn : Requires 'packaging' Python module from now on!
|
|
||||||
#@---------------------------------------------------
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@@ -310,9 +305,8 @@ import pywbem
|
|||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
from optparse import OptionParser,OptionGroup
|
from optparse import OptionParser,OptionGroup
|
||||||
from packaging.version import Version
|
|
||||||
|
|
||||||
version = '20250221'
|
version = '20241025'
|
||||||
|
|
||||||
NS = 'root/cimv2'
|
NS = 'root/cimv2'
|
||||||
hosturl = ''
|
hosturl = ''
|
||||||
@@ -743,18 +737,6 @@ verboseoutput("Found pywbem version "+pywbemversion)
|
|||||||
verboseoutput("Connection to "+hosturl)
|
verboseoutput("Connection to "+hosturl)
|
||||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
|
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS, no_verification=True)
|
||||||
|
|
||||||
# Backward compatibility for older pywbem exceptions, big thanks to Claire M.!
|
|
||||||
if Version(pywbemversion) >= Version("1.0.0"):
|
|
||||||
verboseoutput("pywbem is 1.0.0 or newer")
|
|
||||||
import pywbem._cim_operations as PywbemCimOperations
|
|
||||||
import pywbem._cim_http as PywbemCimHttp
|
|
||||||
import pywbem._exceptions as PywbemExceptions
|
|
||||||
else:
|
|
||||||
verboseoutput("pywbem is older than 1.0.0")
|
|
||||||
import pywbem.cim_operations as PywbemCimOperations
|
|
||||||
import pywbem.cim_http as PywbemCimHttp
|
|
||||||
import pywbem.exceptions as PywbemExceptions
|
|
||||||
|
|
||||||
# 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)
|
||||||
@@ -772,7 +754,7 @@ ExitMsg = ""
|
|||||||
if vendor=='auto':
|
if vendor=='auto':
|
||||||
try:
|
try:
|
||||||
c=wbemclient.EnumerateInstances('CIM_Chassis')
|
c=wbemclient.EnumerateInstances('CIM_Chassis')
|
||||||
except PywbemCimOperations.CIMError as args:
|
except pywbem.cim_operations.CIMError as args:
|
||||||
if ( args[1].find('Socket error') >= 0 ):
|
if ( args[1].find('Socket error') >= 0 ):
|
||||||
print("UNKNOWN: {}".format(args))
|
print("UNKNOWN: {}".format(args))
|
||||||
sys.exit (ExitUnknown)
|
sys.exit (ExitUnknown)
|
||||||
@@ -781,15 +763,11 @@ if vendor=='auto':
|
|||||||
sys.exit (ExitUnknown)
|
sys.exit (ExitUnknown)
|
||||||
else:
|
else:
|
||||||
verboseoutput("Unknown CIM Error: %s" % args)
|
verboseoutput("Unknown CIM Error: %s" % args)
|
||||||
except PywbemExceptions.ConnectionError as args:
|
except pywbem._exceptions.ConnectionError as args:
|
||||||
GlobalStatus = ExitUnknown
|
GlobalStatus = ExitUnknown
|
||||||
print("UNKNOWN: {}".format(args))
|
print("UNKNOWN: {}".format(args))
|
||||||
sys.exit (GlobalStatus)
|
sys.exit (GlobalStatus)
|
||||||
except PywbemExceptions.HTTPError as args:
|
except pywbem.cim_http.AuthError as arg:
|
||||||
GlobalStatus = ExitUnknown
|
|
||||||
print("UNKNOWN: {}".format(args))
|
|
||||||
sys.exit (GlobalStatus)
|
|
||||||
except PywbemCimHttp.AuthError as arg:
|
|
||||||
verboseoutput("Global exit set to UNKNOWN")
|
verboseoutput("Global exit set to UNKNOWN")
|
||||||
GlobalStatus = ExitUnknown
|
GlobalStatus = ExitUnknown
|
||||||
print("UNKNOWN: Authentication Error")
|
print("UNKNOWN: Authentication Error")
|
||||||
@@ -811,7 +789,7 @@ for classe in ClassesToCheck :
|
|||||||
verboseoutput("Check classe "+classe)
|
verboseoutput("Check classe "+classe)
|
||||||
try:
|
try:
|
||||||
instance_list = wbemclient.EnumerateInstances(classe)
|
instance_list = wbemclient.EnumerateInstances(classe)
|
||||||
except PywbemCimOperations.CIMError as args:
|
except pywbem._cim_operations.CIMError as args:
|
||||||
if ( args[1].find('Socket error') >= 0 ):
|
if ( args[1].find('Socket error') >= 0 ):
|
||||||
print("UNKNOWN: {}".format(args))
|
print("UNKNOWN: {}".format(args))
|
||||||
sys.exit (ExitUnknown)
|
sys.exit (ExitUnknown)
|
||||||
@@ -820,15 +798,11 @@ for classe in ClassesToCheck :
|
|||||||
sys.exit (ExitUnknown)
|
sys.exit (ExitUnknown)
|
||||||
else:
|
else:
|
||||||
verboseoutput("Unknown CIM Error: %s" % args)
|
verboseoutput("Unknown CIM Error: %s" % args)
|
||||||
except PywbemExceptions.ConnectionError as args:
|
except pywbem._exceptions.ConnectionError as args:
|
||||||
GlobalStatus = ExitUnknown
|
GlobalStatus = ExitUnknown
|
||||||
print("UNKNOWN: {}".format(args))
|
print("UNKNOWN: {}".format(args))
|
||||||
sys.exit (GlobalStatus)
|
sys.exit (GlobalStatus)
|
||||||
except PywbemExceptions.HTTPError as args:
|
except pywbem._cim_http.AuthError as arg:
|
||||||
GlobalStatus = ExitUnknown
|
|
||||||
print("UNKNOWN: {}".format(args))
|
|
||||||
sys.exit (GlobalStatus)
|
|
||||||
except PywbemCimHttp.AuthError as arg:
|
|
||||||
verboseoutput("Global exit set to UNKNOWN")
|
verboseoutput("Global exit set to UNKNOWN")
|
||||||
GlobalStatus = ExitUnknown
|
GlobalStatus = ExitUnknown
|
||||||
print("UNKNOWN: Authentication Error")
|
print("UNKNOWN: Authentication Error")
|
||||||
|
|||||||
Reference in New Issue
Block a user