From 60b03332f990a14c929123de8c8026cc92fd454b Mon Sep 17 00:00:00 2001 From: Claudio Kuenzler Date: Thu, 15 Jan 2015 15:13:47 +0100 Subject: [PATCH] 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 verboseoutput(" Element Name = "+elementName) TypeError: cannot concatenate 'str' and 'NoneType' objects --- check_esxi_hardware.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 27ddb3e..9a211d3 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -211,6 +211,10 @@ #@ Author : Claudio Kuenzler (www.claudiokuenzler.com) #@ Reason : Output serial number of chassis if a blade server is checked #@--------------------------------------------------- +#@ Date : 20150115 +#@ Author : Andreas Gottwald +#@ Reason : Fix NoneType element bug +#@--------------------------------------------------- import sys import time @@ -219,7 +223,7 @@ import re import string from optparse import OptionParser,OptionGroup -version = '20150109' +version = '20150115' NS = 'root/cimv2' @@ -628,6 +632,8 @@ for classe in ClassesToCheck : for instance in instance_list : sensor_value = "" elementName = instance['ElementName'] + if elementName is None : + elementName = 'Unknown' elementNameValue = elementName verboseoutput(" Element Name = "+elementName)