mirror of
https://github.com/Napsty/check_esxi_hardware.git
synced 2026-02-06 15:15:20 +01:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec7db6479d | ||
|
|
496ae6cf31 | ||
|
|
d8a95f864f | ||
|
|
156016869a | ||
|
|
03f8ca8335 | ||
|
|
3727e67609 | ||
|
|
8c147a204e | ||
|
|
0036c441de | ||
|
|
c806fb4d90 | ||
|
|
6c8a4bfd63 | ||
|
|
fb038edcda | ||
|
|
3f97ca6485 | ||
|
|
b3c0ca4cdd | ||
|
|
e3a43a5dd0 | ||
|
|
8aecf4e7d1 | ||
|
|
60b03332f9 | ||
|
|
16b07977ae | ||
|
|
16e85dcc0c | ||
|
|
d67db0b2ff | ||
|
|
6abc24f522 | ||
|
|
629911c8de |
@@ -24,7 +24,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-2014 Claudio Kuenzler
|
# Copyright (c) 2010-2016 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
|
||||||
@@ -35,12 +35,15 @@
|
|||||||
# Copyright (c) 2011 Ian Chard
|
# Copyright (c) 2011 Ian Chard
|
||||||
# Copyright (c) 2012 Craig Hart
|
# Copyright (c) 2012 Craig Hart
|
||||||
# Copyright (c) 2013 Carl R. Friend
|
# 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:
|
# 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
|
# http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf
|
||||||
# http://www.vmware.com/support/developer/cim-sdk/smash/u2/ga/apirefdoc/
|
# http://www.vmware.com/support/developer/cim-sdk/smash/u2/ga/apirefdoc/
|
||||||
#
|
#
|
||||||
# The VMware 5.x CIM API is documented here:
|
# The VMware 5.x CIM API is documented here:
|
||||||
# http://pubs.vmware.com/vsphere-50/index.jsp?nav=/5_1_1
|
# http://pubs.vmware.com/vsphere-50/index.jsp?nav=/5_1_1
|
||||||
#
|
#
|
||||||
# This Nagios plugin is maintained here:
|
# This Nagios plugin is maintained here:
|
||||||
@@ -189,7 +192,7 @@
|
|||||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
#@ Reason : Added workaround for Dell PE x620 where "System Board 1 Riser Config Err 0: Connected"
|
#@ Reason : Added workaround for Dell PE x620 where "System Board 1 Riser Config Err 0: Connected"
|
||||||
#@ element outputs wrong return code. Dell, please fix that.
|
#@ element outputs wrong return code. Dell, please fix that.
|
||||||
#@ Added web-link to VMware CIM API 5.x at top of script.
|
#@ Added web-link to VMware CIM API 5.x at top of script.
|
||||||
#@---------------------------------------------------
|
#@---------------------------------------------------
|
||||||
#@ Date : 20130424
|
#@ Date : 20130424
|
||||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
@@ -207,17 +210,43 @@
|
|||||||
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
#@ Reason : Another two workarounds for Dell systems (VGA Cable Pres 0, Add-in Card 4 PEM Presence 0)
|
#@ Reason : Another two workarounds for Dell systems (VGA Cable Pres 0, Add-in Card 4 PEM Presence 0)
|
||||||
#@---------------------------------------------------
|
#@---------------------------------------------------
|
||||||
|
#@ Date : 20150109
|
||||||
|
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
|
||||||
|
#@ Reason : Output serial number of chassis if a blade server is checked
|
||||||
|
#@---------------------------------------------------
|
||||||
|
#@ Date : 20150119
|
||||||
|
#@ 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)
|
||||||
|
#@---------------------------------------------------
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import pywbem
|
import pywbem
|
||||||
import re
|
import re
|
||||||
import string
|
import pkg_resources
|
||||||
from optparse import OptionParser,OptionGroup
|
from optparse import OptionParser,OptionGroup
|
||||||
|
|
||||||
version = '20140319'
|
version = '20160411'
|
||||||
|
|
||||||
NS = 'root/cimv2'
|
NS = 'root/cimv2'
|
||||||
|
hosturl = ''
|
||||||
|
|
||||||
# define classes to check 'OperationStatus' instance
|
# define classes to check 'OperationStatus' instance
|
||||||
ClassesToCheck = [
|
ClassesToCheck = [
|
||||||
@@ -315,6 +344,9 @@ ExitWarning = 1
|
|||||||
ExitCritical = 2
|
ExitCritical = 2
|
||||||
ExitUnknown = 3
|
ExitUnknown = 3
|
||||||
|
|
||||||
|
# Special handling for blade servers
|
||||||
|
isblade = "no"
|
||||||
|
|
||||||
def dell_country(country):
|
def dell_country(country):
|
||||||
if country == 'at': # Austria
|
if country == 'at': # Austria
|
||||||
return 'at/de/'
|
return 'at/de/'
|
||||||
@@ -553,12 +585,28 @@ if os_platform != "win32":
|
|||||||
on_windows = False
|
on_windows = False
|
||||||
import signal
|
import signal
|
||||||
def handler(signum, frame):
|
def handler(signum, frame):
|
||||||
print 'CRITICAL: Execution time too long!'
|
print 'UNKNOWN: Execution time too long!'
|
||||||
sys.exit(ExitCritical)
|
sys.exit(ExitUnknown)
|
||||||
|
|
||||||
# connection to host
|
# connection to host
|
||||||
verboseoutput("Connection to "+hosturl)
|
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
|
||||||
|
elif '0.8.' in 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.
|
# 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:
|
||||||
@@ -607,20 +655,21 @@ for classe in ClassesToCheck :
|
|||||||
instance_list = wbemclient.EnumerateInstances(classe)
|
instance_list = wbemclient.EnumerateInstances(classe)
|
||||||
except pywbem.cim_operations.CIMError,args:
|
except pywbem.cim_operations.CIMError,args:
|
||||||
if ( args[1].find('Socket error') >= 0 ):
|
if ( args[1].find('Socket error') >= 0 ):
|
||||||
print "CRITICAL: %s" %args
|
print "UNKNOWN: %s" %args
|
||||||
sys.exit (ExitCritical)
|
sys.exit (ExitUnknown)
|
||||||
else:
|
else:
|
||||||
verboseoutput("Unknown CIM Error: %s" % args)
|
verboseoutput("Unknown CIM Error: %s" % args)
|
||||||
except pywbem.cim_http.AuthError,arg:
|
except pywbem.cim_http.AuthError,arg:
|
||||||
verboseoutput("Global exit set to UNKNOWN")
|
verboseoutput("Global exit set to UNKNOWN")
|
||||||
GlobalStatus = ExitCritical
|
GlobalStatus = ExitUnknown
|
||||||
print "UNKNOWN: Authentication Error"
|
print "UNKNOWN: Authentication Error"
|
||||||
sys.exit (GlobalStatus)
|
sys.exit (GlobalStatus)
|
||||||
else:
|
else:
|
||||||
# GlobalStatus = ExitOK #ARR
|
# GlobalStatus = ExitOK #ARR
|
||||||
for instance in instance_list :
|
for instance in instance_list :
|
||||||
sensor_value = ""
|
|
||||||
elementName = instance['ElementName']
|
elementName = instance['ElementName']
|
||||||
|
if elementName is None :
|
||||||
|
elementName = 'Unknown'
|
||||||
elementNameValue = elementName
|
elementNameValue = elementName
|
||||||
verboseoutput(" Element Name = "+elementName)
|
verboseoutput(" Element Name = "+elementName)
|
||||||
|
|
||||||
@@ -642,6 +691,7 @@ for classe in ClassesToCheck :
|
|||||||
man = 'Unknown Manufacturer'
|
man = 'Unknown Manufacturer'
|
||||||
verboseoutput(" Manufacturer = "+man)
|
verboseoutput(" Manufacturer = "+man)
|
||||||
SerialNumber = instance[u'SerialNumber']
|
SerialNumber = instance[u'SerialNumber']
|
||||||
|
SerialChassis = instance[u'SerialNumber']
|
||||||
if SerialNumber:
|
if SerialNumber:
|
||||||
verboseoutput(" SerialNumber = "+SerialNumber)
|
verboseoutput(" SerialNumber = "+SerialNumber)
|
||||||
server_info = man + ' '
|
server_info = man + ' '
|
||||||
@@ -655,6 +705,7 @@ for classe in ClassesToCheck :
|
|||||||
SerialNumber = instance[u'SerialNumber']
|
SerialNumber = instance[u'SerialNumber']
|
||||||
if SerialNumber:
|
if SerialNumber:
|
||||||
verboseoutput(" SerialNumber = "+SerialNumber)
|
verboseoutput(" SerialNumber = "+SerialNumber)
|
||||||
|
isblade = "yes"
|
||||||
|
|
||||||
# Report detail of Numeric Sensors and generate nagios perfdata
|
# Report detail of Numeric Sensors and generate nagios perfdata
|
||||||
|
|
||||||
@@ -761,8 +812,8 @@ for classe in ClassesToCheck :
|
|||||||
# Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it
|
# 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 Riser Config Err 0: Connected")
|
||||||
ignore_list.append("System Board 1 LCD Cable Pres 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("System Board 1 VGA Cable Pres 0: Connected")
|
||||||
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
|
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
|
||||||
if instance['OperationalStatus'] is not None :
|
if instance['OperationalStatus'] is not None :
|
||||||
elementStatus = instance['OperationalStatus'][0]
|
elementStatus = instance['OperationalStatus'][0]
|
||||||
verboseoutput(" Element Op Status = %d" % elementStatus)
|
verboseoutput(" Element Op Status = %d" % elementStatus)
|
||||||
@@ -813,6 +864,10 @@ if (urlise_country != '') :
|
|||||||
SerialNumber = urlised_serialnumber(vendor,urlise_country,SerialNumber)
|
SerialNumber = urlised_serialnumber(vendor,urlise_country,SerialNumber)
|
||||||
server_info = urlised_server_info(vendor,urlise_country,server_info)
|
server_info = urlised_server_info(vendor,urlise_country,server_info)
|
||||||
|
|
||||||
|
# If this is a blade server, also output chassis serial number as additional info
|
||||||
|
if (isblade == "yes") :
|
||||||
|
SerialNumber += " Chassis S/N: %s " % (SerialChassis)
|
||||||
|
|
||||||
# Output performance data
|
# Output performance data
|
||||||
perf = '|'
|
perf = '|'
|
||||||
if perfdata:
|
if perfdata:
|
||||||
|
|||||||
Reference in New Issue
Block a user