1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2024-10-22 12:13:46 +02:00

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).
This commit is contained in:
stefaro 2015-11-11 09:57:05 +02:00
parent 3727e67609
commit 03f8ca8335

View File

@ -37,6 +37,7 @@
# 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
@ -225,18 +226,25 @@
#@ 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 : Removed no SSL tryout on pywbem v 0.0.7 (default version doesn't have no_verification).
#@ Reason : Added global hosturl variable declaration after imports.
#@ Reason : Added "Front Panel Board 1 FP LCD Cable 0: Connected" to ignore list (LENOVO System x3550 M5).
#@---------------------------------------------------
import sys
import time
import pywbem
import re
import string
import pkg_resources
from optparse import OptionParser,OptionGroup
version = '20150710'
version = '20151111'
NS = 'root/cimv2'
hosturl = 'https://esxi.localdomain'
# define classes to check 'OperationStatus' instance
ClassesToCheck = [
@ -588,9 +596,9 @@ if '0.7.0' in pywbemversion:
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)
verboseoutput("Connection error")
print "UNKNOWN: unable to connect"
sys.exit (ExitUnknown)
else:
verboseoutput("Connection worked")
wbemclient = pywbem.WBEMConnection(hosturl, (user,password))
@ -657,7 +665,6 @@ for classe in ClassesToCheck :
else:
# GlobalStatus = ExitOK #ARR
for instance in instance_list :
sensor_value = ""
elementName = instance['ElementName']
if elementName is None :
elementName = 'Unknown'
@ -804,6 +811,7 @@ for classe in ClassesToCheck :
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("Front Panel Board 1 FP LCD Cable 0: Connected")
ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
if instance['OperationalStatus'] is not None :
elementStatus = instance['OperationalStatus'][0]
@ -889,4 +897,3 @@ else:
print "%s- Server: %s %s %s%s" % (ExitMsg, server_info, SerialNumber, bios_info, perf)
sys.exit (GlobalStatus)