mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2026-02-06 15:15:20 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89f9e505c3 | ||
|
|
82a4156e34 | ||
|
|
1f7c3b5927 | ||
|
|
ced39ad416 |
@@ -235,6 +235,14 @@
|
|||||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
#@ Reason : Distinguish between pywbem 0.7 and 0.8 (which is now released)
|
#@ Reason : Distinguish between pywbem 0.7 and 0.8 (which is now released)
|
||||||
#@---------------------------------------------------
|
#@---------------------------------------------------
|
||||||
|
#@ Date : 20160531
|
||||||
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
|
#@ Reason : Add parameter for variable CIM port (useful when behind NAT)
|
||||||
|
#@---------------------------------------------------
|
||||||
|
#@ Date : 20161013
|
||||||
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
|
#@ Reason : Added support for pywbem 0.9.x (and upcoming releases)
|
||||||
|
#@---------------------------------------------------
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@@ -243,7 +251,7 @@ import re
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
from optparse import OptionParser,OptionGroup
|
from optparse import OptionParser,OptionGroup
|
||||||
|
|
||||||
version = '20160411'
|
version = '20161013'
|
||||||
|
|
||||||
NS = 'root/cimv2'
|
NS = 'root/cimv2'
|
||||||
hosturl = ''
|
hosturl = ''
|
||||||
@@ -307,6 +315,9 @@ perf_Prefix = {
|
|||||||
# host name
|
# host name
|
||||||
hostname=''
|
hostname=''
|
||||||
|
|
||||||
|
# cim port
|
||||||
|
cimport=''
|
||||||
|
|
||||||
# user
|
# user
|
||||||
user=''
|
user=''
|
||||||
|
|
||||||
@@ -461,14 +472,11 @@ def verboseoutput(message) :
|
|||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
def getopts() :
|
def getopts() :
|
||||||
global hosturl,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan
|
global hosturl,cimport,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan
|
||||||
usage = "usage: %prog https://hostname user password system [verbose]\n" \
|
usage = "usage: %prog -H hostname -U username -P password [-C port -V system -v -p -I XX]\n" \
|
||||||
"example: %prog https://my-shiny-new-vmware-server root fakepassword dell\n\n" \
|
"example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -C 5989 -V auto -I uk\n\n" \
|
||||||
"or, using new style options:\n\n" \
|
|
||||||
"usage: %prog -H hostname -U username -P password [-V system -v -p -I XX]\n" \
|
|
||||||
"example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -V auto -I uk\n\n" \
|
|
||||||
"or, verbosely:\n\n" \
|
"or, verbosely:\n\n" \
|
||||||
"usage: %prog --host=hostname --user=username --pass=password [--vendor=system --verbose --perfdata --html=XX]\n"
|
"usage: %prog --host=hostname --user=username --pass=password [--cimport=port --vendor=system --verbose --perfdata --html=XX]\n"
|
||||||
|
|
||||||
parser = OptionParser(usage=usage, version="%prog "+version)
|
parser = OptionParser(usage=usage, version="%prog "+version)
|
||||||
group1 = OptionGroup(parser, 'Mandatory parameters')
|
group1 = OptionGroup(parser, 'Mandatory parameters')
|
||||||
@@ -479,6 +487,7 @@ def getopts() :
|
|||||||
group1.add_option("-P", "--pass", dest="password", \
|
group1.add_option("-P", "--pass", dest="password", \
|
||||||
help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS")
|
help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS")
|
||||||
|
|
||||||
|
group2.add_option("-C", "--cimport", dest="cimport", help="CIM port (default 5989)", metavar="CIMPORT")
|
||||||
group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \
|
group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \
|
||||||
metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown")
|
metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown")
|
||||||
group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \
|
group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \
|
||||||
@@ -546,6 +555,7 @@ def getopts() :
|
|||||||
|
|
||||||
user=options.user
|
user=options.user
|
||||||
password=options.password
|
password=options.password
|
||||||
|
cimport=options.cimport
|
||||||
vendor=options.vendor.lower()
|
vendor=options.vendor.lower()
|
||||||
verbose=options.verbose
|
verbose=options.verbose
|
||||||
perfdata=options.perfdata
|
perfdata=options.perfdata
|
||||||
@@ -588,6 +598,10 @@ if os_platform != "win32":
|
|||||||
print 'UNKNOWN: Execution time too long!'
|
print 'UNKNOWN: Execution time too long!'
|
||||||
sys.exit(ExitUnknown)
|
sys.exit(ExitUnknown)
|
||||||
|
|
||||||
|
if cimport:
|
||||||
|
verboseoutput("Using manually defined CIM port "+cimport)
|
||||||
|
hosturl += ':'+cimport
|
||||||
|
|
||||||
# connection to host
|
# connection to host
|
||||||
verboseoutput("Connection to "+hosturl)
|
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
|
||||||
@@ -605,7 +619,7 @@ if '0.7.' in pywbemversion:
|
|||||||
verboseoutput("Connection worked")
|
verboseoutput("Connection worked")
|
||||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
|
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
|
||||||
# pywbem 0.8.0 and later
|
# pywbem 0.8.0 and later
|
||||||
elif '0.8.' in pywbemversion:
|
else:
|
||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user