1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2026-02-06 15:15:20 +01:00

21 Commits

Author SHA1 Message Date
Claudio Kuenzler
ec7db6479d Merge pull request #16 from Napsty/pywbem-versions
Distinguish between pywbem 0.7 and 0.8
2016-04-11 15:21:16 +02:00
Claudio Kuenzler
496ae6cf31 Distinguish between pywbem 0.7 and 0.8 2016-04-11 15:19:37 +02:00
Claudio Kuenzler
d8a95f864f Merge pull request #14 from stefaro/patch-1
Merge pull request from Stefan Roos. Declare hosturl variable. Remove sensor_value variable (it's not used).
2016-04-07 13:51:36 +02:00
Stefan Roos
156016869a Update check_esxi_hardware.py
Removed some modifications.
2016-04-07 10:11:40 +03:00
stefaro
03f8ca8335 Minor changes and cleanup
Removed unused sensor_value variable and string import.
Removed no SSL tryout on pywbem v 0.0.7 (default version doesn't have no_verification).
Added global hosturl variable declaration after imports.
Added "Front Panel Board 1 FP LCD Cable 0: Connected" to ignore list (LENOVO System x3550 M5).
2015-11-11 09:57:05 +02:00
Claudio Kuenzler
3727e67609 Exit Unknown instead of Critical for non-essential errors 2015-07-10 09:56:25 +02:00
Claudio Kuenzler
8c147a204e Merge pull request #12 from giner/patch-1
check_esxi_hardware.py: unknown instead of crit
2015-07-10 09:45:02 +02:00
Napsty
0036c441de Change version number for public release 2015-06-26 14:50:10 +02:00
Napsty
c806fb4d90 Change version number for public release 2015-06-26 14:30:42 +02:00
Napsty
6c8a4bfd63 Extended pywbem version compatibility 2015-06-10 12:47:12 +02:00
Stanislav German-Evtushenko
fb038edcda check_esxi_hardware.py: revert last change
1. This change was wrong and inappropriate.
2. The issue I tried to fix was caused by the bug in python library pywbem: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780264
2015-06-01 19:52:59 +03:00
Napsty
3f97ca6485 Added support for patched pywbem 0.7.0 and new version 0.8.0, handle SSL error exception 2015-05-12 08:45:32 +02:00
Stanislav German-Evtushenko
b3c0ca4cdd check_esxi_hardware.py: force exit on timeout
Replace sys.exit by os._exit to be sure that the script stops on timeout immediately and does not produce false-positive results (usually it comes to WARNING).
2015-04-07 15:56:00 +03:00
Stanislav German-Evtushenko
e3a43a5dd0 check_esxi_hardware.py: unknown instead of crit
Set status to unknown instead of critical for timeouts, authentication errors and such things as those issues are critical for the check itself but not for the service.
2015-03-16 15:16:47 +03:00
Napsty
8aecf4e7d1 Change version number for public release 2015-01-19 16:48:38 +01:00
Claudio Kuenzler
60b03332f9 Fix NoneType element bug
Andreas Gottwald sent a patch which fixes an issue, when the CIM element was a "NoneType" element but the plugin wanted to read a string from it. 

    Traceback (most recent call last):
     File "./check_esxi_hardware.py", line 629, in <module>
    verboseoutput("  Element Name = "+elementName)
    TypeError: cannot concatenate 'str' and 'NoneType' objects
2015-01-15 15:13:47 +01:00
Claudio Kuenzler
16b07977ae Adapt date
The change for the chassis serial number was already prepared a few months ago but I only found time today to do the merge and the release. Therefore adapting the date in history and version variable to today (20150109)
2015-01-09 11:56:17 +01:00
Claudio Kuenzler
16e85dcc0c Merge pull request #10 from Napsty/chassissn
Added Serial Number for Chassis
2015-01-09 11:54:31 +01:00
Napsty
d67db0b2ff Fixed uninitialized variable isblade 2014-09-16 13:27:48 +02:00
Napsty
6abc24f522 Removed autoindent, added spaced instead 2014-09-09 17:30:55 +02:00
Napsty
629911c8de Output serial number of chassis if a blade server is checked 2014-09-09 17:28:53 +02:00

View File

@@ -24,7 +24,7 @@
# Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin
# 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 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin
@@ -35,6 +35,9 @@
# Copyright (c) 2011 Ian Chard
# 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
@@ -207,17 +210,43 @@
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ 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 time
import pywbem
import re
import string
import pkg_resources
from optparse import OptionParser,OptionGroup
version = '20140319'
version = '20160411'
NS = 'root/cimv2'
hosturl = ''
# define classes to check 'OperationStatus' instance
ClassesToCheck = [
@@ -315,6 +344,9 @@ ExitWarning = 1
ExitCritical = 2
ExitUnknown = 3
# Special handling for blade servers
isblade = "no"
def dell_country(country):
if country == 'at': # Austria
return 'at/de/'
@@ -553,12 +585,28 @@ 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)
# 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
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.
if on_windows == False and timeout > 0:
@@ -607,20 +655,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'
elementNameValue = elementName
verboseoutput(" Element Name = "+elementName)
@@ -642,6 +691,7 @@ for classe in ClassesToCheck :
man = 'Unknown Manufacturer'
verboseoutput(" Manufacturer = "+man)
SerialNumber = instance[u'SerialNumber']
SerialChassis = instance[u'SerialNumber']
if SerialNumber:
verboseoutput(" SerialNumber = "+SerialNumber)
server_info = man + ' '
@@ -655,6 +705,7 @@ for classe in ClassesToCheck :
SerialNumber = instance[u'SerialNumber']
if SerialNumber:
verboseoutput(" SerialNumber = "+SerialNumber)
isblade = "yes"
# Report detail of Numeric Sensors and generate nagios perfdata
@@ -813,6 +864,10 @@ if (urlise_country != '') :
SerialNumber = urlised_serialnumber(vendor,urlise_country,SerialNumber)
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
perf = '|'
if perfdata: