@@ -24,7 +24,7 @@
# Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider
-# Copyright (c) 2010-2015 Claudio Kuenzler
+# Copyright (c) 2010-2018 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin
@@ -37,6 +37,8 @@
# Copyright (c) 2013 Carl R. Friend
# Copyright (c) 2015 Andreas Gottwald
# Copyright (c) 2015 Stanislav German-Evtushenko
+# Copyright (c) 2015 Stefan Roos
+# Copyright (c) 2018 Peter Newman
#
# 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 +227,52 @@
#@ 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)
+#@---------------------------------------------------
+#@ Date : 20160531
+#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
+#@ Reason : Add parameter for variable CIM port (useful when behind NAT)
+#@---------------------------------------------------
+#@ Date : 20161013
+#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
+#@ Reason : Added support for pywbem 0.9.x (and upcoming releases)
+#@---------------------------------------------------
+#@ Date : 20170905
+#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
+#@ Reason : Added option to ignore LCD/Display related elements (--no-lcd)
+#@---------------------------------------------------
+#@ Date : 20180329
+#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
+#@ Reason : Try to use internal pywbem function to determine version
+#@---------------------------------------------------
+#@ Date : 20180411
+#@ Author : Peter Newman
+#@ Reason : Throw an unknown if we can't fetch the data for some reason
+#@---------------------------------------------------
+#@ Date : 20181001
+#@ Author : Claudio Kuenzler
+#@ Reason : python3 compatibility
+#@---------------------------------------------------
+from __future__ import print_function
import sys
import time
import pywbem
import re
-import string
import pkg_resources
from optparse import OptionParser,OptionGroup
-version = '20150710'
+version = '20181001'
NS = 'root/cimv2'
+hosturl = ''
# define classes to check 'OperationStatus' instance
ClassesToCheck = [
@@ -297,6 +333,9 @@
# host name
hostname=''
+# cim port
+cimport=''
+
# user
user=''
@@ -327,6 +366,7 @@
get_current = True
get_temp = True
get_fan = True
+get_lcd = True
# define exit codes
ExitOK = 0
@@ -446,19 +486,16 @@
def verboseoutput(message) :
if verbose:
- print "%s %s" % (time.strftime("%Y%m%d %H:%M:%S"), message)
+ print(time.strftime("%Y%m%d %H:%M:%S"), message)
# ----------------------------------------------------------------------
def getopts() :
- global hosturl,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan
- usage = "usage: %prog https://hostname user password system [verbose]\n" \
- "example: %prog https://my-shiny-new-vmware-server root fakepassword dell\n\n" \
- "or, using new style options:\n\n" \
- "usage: %prog -H hostname -U username -P password [-V system -v -p -I XX]\n" \
- "example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -V auto -I uk\n\n" \
+ global hosturl,cimport,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan,get_lcd
+ usage = "usage: %prog -H hostname -U username -P password [-C port -V system -v -p -I XX]\n" \
+ "example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -C 5989 -V auto -I uk\n\n" \
"or, verbosely:\n\n" \
- "usage: %prog --host=hostname --user=username --pass=password [--vendor=system --verbose --perfdata --html=XX]\n"
+ "usage: %prog --host=hostname --user=username --pass=password [--cimport=port --vendor=system --verbose --perfdata --html=XX]\n"
parser = OptionParser(usage=usage, version="%prog "+version)
group1 = OptionGroup(parser, 'Mandatory parameters')
@@ -469,6 +506,7 @@
group1.add_option("-P", "--pass", dest="password", \
help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS")
+ group2.add_option("-C", "--cimport", dest="cimport", help="CIM port (default 5989)", metavar="CIMPORT")
group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \
metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown")
group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \
@@ -491,20 +529,22 @@
help="don't collect temperature performance data")
group2.add_option("--no-fan", action="store_false", dest="get_fan", default=True, \
help="don't collect fan performance data")
+ group2.add_option("--no-lcd", action="store_false", dest="get_lcd", default=True, \
+ help="don't collect lcd/front display status")
parser.add_option_group(group1)
parser.add_option_group(group2)
# check input arguments
if len(sys.argv) < 2:
- print "no parameters specified\n"
+ print("no parameters specified\n")
parser.print_help()
sys.exit(-1)
# if first argument starts with 'https://' we have old-style parameters, so handle in old way
if re.match("https://",sys.argv[1]):
# check input arguments
if len(sys.argv) < 5:
- print "too few parameters\n"
+ print("too few parameters\n")
parser.print_help()
sys.exit(-1)
if len(sys.argv) > 5 :
@@ -522,7 +562,7 @@
mandatories = ['host', 'user', 'password']
for m in mandatories:
if not options.__dict__[m]:
- print "mandatory parameter '--" + m + "' is missing\n"
+ print("mandatory parameter '--" + m + "' is missing\n")
parser.print_help()
sys.exit(-1)
@@ -536,6 +576,7 @@
user=options.user
password=options.password
+ cimport=options.cimport
vendor=options.vendor.lower()
verbose=options.verbose
perfdata=options.perfdata
@@ -547,6 +588,7 @@
get_current=options.get_current
get_temp=options.get_temp
get_fan=options.get_fan
+ get_lcd=options.get_lcd
# if user or password starts with 'file:', use the first string in file as user, second as password
if (re.match('^file:', user) or re.match('^file:', password)):
@@ -575,15 +617,33 @@
on_windows = False
import signal
def handler(signum, frame):
- print 'UNKNOWN: Execution time too long!'
+ print('UNKNOWN: Execution time too long!')
sys.exit(ExitUnknown)
+if cimport:
+ verboseoutput("Using manually defined CIM port "+cimport)
+ hosturl += ':'+cimport
+
+# Append lcd related elements to ignore list if --no-lcd was used
+verboseoutput("LCD Status: %s" % get_lcd)
+if not get_lcd:
+ 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("Front Panel Board 1 FP LCD Cable 0: Config Error")
+
# connection to host
verboseoutput("Connection to "+hosturl)
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
-pywbemversion = pkg_resources.get_distribution("pywbem").version
+try:
+ pywbemversion = pywbem.__version__
|