From 03f8ca8335ff7b280b80d0872af85270c71c2483 Mon Sep 17 00:00:00 2001 From: stefaro Date: Wed, 11 Nov 2015 09:57:05 +0200 Subject: [PATCH 1/2] 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). --- check_esxi_hardware.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 7537f66..9b3a8ad 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -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) - From 156016869a0df2e4103267852d9442440de2ab3f Mon Sep 17 00:00:00 2001 From: Stefan Roos Date: Thu, 7 Apr 2016 10:11:40 +0300 Subject: [PATCH 2/2] Update check_esxi_hardware.py Removed some modifications. --- check_esxi_hardware.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 9b3a8ad..29a7163 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -229,9 +229,7 @@ #@ 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 @@ -244,7 +242,7 @@ from optparse import OptionParser,OptionGroup version = '20151111' NS = 'root/cimv2' -hosturl = 'https://esxi.localdomain' +hosturl = '' # define classes to check 'OperationStatus' instance ClassesToCheck = [ @@ -596,9 +594,9 @@ if '0.7.0' in pywbemversion: conntest = pywbem.WBEMConnection(hosturl, (user,password)) c = conntest.EnumerateInstances('CIM_Card') except: - verboseoutput("Connection error") - print "UNKNOWN: unable to connect" - sys.exit (ExitUnknown) + #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)) @@ -811,7 +809,6 @@ 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]