mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2026-02-06 15:15:20 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89f9e505c3 | ||
|
|
82a4156e34 | ||
|
|
1f7c3b5927 | ||
|
|
ced39ad416 | ||
|
|
ec7db6479d | ||
|
|
496ae6cf31 | ||
|
|
d8a95f864f | ||
|
|
156016869a | ||
|
|
03f8ca8335 | ||
|
|
3727e67609 | ||
|
|
8c147a204e | ||
|
|
0036c441de | ||
|
|
c806fb4d90 | ||
|
|
6c8a4bfd63 | ||
|
|
fb038edcda | ||
|
|
3f97ca6485 | ||
|
|
b3c0ca4cdd | ||
|
|
e3a43a5dd0 |
@@ -24,7 +24,7 @@
|
||||
# Copyright (c) 2008 David Ligeret
|
||||
# Copyright (c) 2009 Joshua Daniel Franklin
|
||||
# Copyright (c) 2010 Branden Schneider
|
||||
# Copyright (c) 2010-2015 Claudio Kuenzler
|
||||
# Copyright (c) 2010-2016 Claudio Kuenzler
|
||||
# Copyright (c) 2010 Samir Ibradzic
|
||||
# Copyright (c) 2010 Aaron Rogers
|
||||
# Copyright (c) 2011 Ludovic Hutin
|
||||
@@ -36,6 +36,8 @@
|
||||
# Copyright (c) 2012 Craig Hart
|
||||
# Copyright (c) 2013 Carl R. Friend
|
||||
# Copyright (c) 2015 Andreas Gottwald
|
||||
# Copyright (c) 2015 Stanislav German-Evtushenko
|
||||
# Copyright (c) 2015 Stefan Roos
|
||||
#
|
||||
# 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
|
||||
@@ -216,17 +218,43 @@
|
||||
#@ Author : Andreas Gottwald
|
||||
#@ Reason : Fix NoneType element bug
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20150626
|
||||
#@ 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
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20150710
|
||||
#@ Author : Stanislav German-Evtushenko
|
||||
#@ Reason : Exit Unknown instead of Critical for timeouts and auth errors
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20151111
|
||||
#@ Author : Stefan Roos
|
||||
#@ Reason : Removed unused sensor_value variable and string import.
|
||||
#@ Reason : Added global hosturl variable declaration after imports.
|
||||
#@---------------------------------------------------
|
||||
#@ Date : 20160411
|
||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||
#@ 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 time
|
||||
import pywbem
|
||||
import re
|
||||
import string
|
||||
import pkg_resources
|
||||
from optparse import OptionParser,OptionGroup
|
||||
|
||||
version = '20150119'
|
||||
version = '20161013'
|
||||
|
||||
NS = 'root/cimv2'
|
||||
hosturl = ''
|
||||
|
||||
# define classes to check 'OperationStatus' instance
|
||||
ClassesToCheck = [
|
||||
@@ -287,6 +315,9 @@ perf_Prefix = {
|
||||
# host name
|
||||
hostname=''
|
||||
|
||||
# cim port
|
||||
cimport=''
|
||||
|
||||
# user
|
||||
user=''
|
||||
|
||||
@@ -441,14 +472,11 @@ def verboseoutput(message) :
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
def getopts() :
|
||||
global hosturl,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" \
|
||||
"example: %prog https://my-shiny-new-vmware-server root fakepassword dell\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" \
|
||||
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 -H hostname -U username -P password [-C port -V system -v -p -I XX]\n" \
|
||||
"example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -C 5989 -V auto -I uk\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)
|
||||
group1 = OptionGroup(parser, 'Mandatory parameters')
|
||||
@@ -459,6 +487,7 @@ def getopts() :
|
||||
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")
|
||||
|
||||
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)", \
|
||||
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, \
|
||||
@@ -526,6 +555,7 @@ def getopts() :
|
||||
|
||||
user=options.user
|
||||
password=options.password
|
||||
cimport=options.cimport
|
||||
vendor=options.vendor.lower()
|
||||
verbose=options.verbose
|
||||
perfdata=options.perfdata
|
||||
@@ -565,12 +595,32 @@ if os_platform != "win32":
|
||||
on_windows = False
|
||||
import signal
|
||||
def handler(signum, frame):
|
||||
print 'CRITICAL: Execution time too long!'
|
||||
sys.exit(ExitCritical)
|
||||
print 'UNKNOWN: Execution time too long!'
|
||||
sys.exit(ExitUnknown)
|
||||
|
||||
if cimport:
|
||||
verboseoutput("Using manually defined CIM port "+cimport)
|
||||
hosturl += ':'+cimport
|
||||
|
||||
# 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
|
||||
verboseoutput("Found pywbem version "+pywbemversion)
|
||||
if '0.7.' in pywbemversion:
|
||||
try:
|
||||
conntest = pywbem.WBEMConnection(hosturl, (user,password))
|
||||
c = conntest.EnumerateInstances('CIM_Card')
|
||||
except:
|
||||
#raise
|
||||
verboseoutput("Connection error, disable SSL certification verification (probably patched pywbem)")
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), no_verification=True)
|
||||
else:
|
||||
verboseoutput("Connection worked")
|
||||
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
|
||||
# pywbem 0.8.0 and later
|
||||
else:
|
||||
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:
|
||||
@@ -619,22 +669,21 @@ for classe in ClassesToCheck :
|
||||
instance_list = wbemclient.EnumerateInstances(classe)
|
||||
except pywbem.cim_operations.CIMError,args:
|
||||
if ( args[1].find('Socket error') >= 0 ):
|
||||
print "CRITICAL: %s" %args
|
||||
sys.exit (ExitCritical)
|
||||
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 = ExitCritical
|
||||
GlobalStatus = ExitUnknown
|
||||
print "UNKNOWN: Authentication Error"
|
||||
sys.exit (GlobalStatus)
|
||||
else:
|
||||
# GlobalStatus = ExitOK #ARR
|
||||
for instance in instance_list :
|
||||
sensor_value = ""
|
||||
elementName = instance['ElementName']
|
||||
if elementName is None :
|
||||
elementName = 'Unknown'
|
||||
elementName = 'Unknown'
|
||||
elementNameValue = elementName
|
||||
verboseoutput(" Element Name = "+elementName)
|
||||
|
||||
@@ -777,8 +826,8 @@ for classe in ClassesToCheck :
|
||||
# Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it
|
||||
ignore_list.append("System Board 1 Riser Config Err 0: Connected")
|
||||
ignore_list.append("System Board 1 LCD Cable Pres 0: Connected")
|
||||
ignore_list.append("System Board 1 VGA Cable Pres 0: Connected")
|
||||
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
|
||||
ignore_list.append("System Board 1 VGA Cable Pres 0: Connected")
|
||||
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
|
||||
if instance['OperationalStatus'] is not None :
|
||||
elementStatus = instance['OperationalStatus'][0]
|
||||
verboseoutput(" Element Op Status = %d" % elementStatus)
|
||||
|
||||
Reference in New Issue
Block a user