1
0
mirror of https://github.com/Napsty/check_esxi_hardware.git synced 2024-11-24 03:13:50 +01:00

Merge pull request #23 from Napsty/lcd

Option --no-lcd
This commit is contained in:
Claudio Kuenzler 2017-09-05 21:08:58 +02:00 committed by GitHub
commit ccb315d2d7

View File

@ -24,7 +24,7 @@
# Copyright (c) 2008 David Ligeret # Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin # Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider # Copyright (c) 2010 Branden Schneider
# Copyright (c) 2010-2016 Claudio Kuenzler # Copyright (c) 2010-2017 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic # Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers # Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin # Copyright (c) 2011 Ludovic Hutin
@ -243,6 +243,10 @@
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com) #@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Added support for pywbem 0.9.x (and upcoming releases) #@ 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)
#@---------------------------------------------------
import sys import sys
import time import time
@ -251,7 +255,7 @@ import re
import pkg_resources import pkg_resources
from optparse import OptionParser,OptionGroup from optparse import OptionParser,OptionGroup
version = '20161013' version = '20170905'
NS = 'root/cimv2' NS = 'root/cimv2'
hosturl = '' hosturl = ''
@ -348,6 +352,7 @@ get_volts = True
get_current = True get_current = True
get_temp = True get_temp = True
get_fan = True get_fan = True
get_lcd = True
# define exit codes # define exit codes
ExitOK = 0 ExitOK = 0
@ -472,7 +477,7 @@ def verboseoutput(message) :
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
def getopts() : def getopts() :
global hosturl,cimport,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan 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" \ 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" \ "example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -C 5989 -V auto -I uk\n\n" \
"or, verbosely:\n\n" \ "or, verbosely:\n\n" \
@ -510,6 +515,8 @@ def getopts() :
help="don't collect temperature performance data") help="don't collect temperature performance data")
group2.add_option("--no-fan", action="store_false", dest="get_fan", default=True, \ group2.add_option("--no-fan", action="store_false", dest="get_fan", default=True, \
help="don't collect fan performance data") 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(group1)
parser.add_option_group(group2) parser.add_option_group(group2)
@ -567,6 +574,7 @@ def getopts() :
get_current=options.get_current get_current=options.get_current
get_temp=options.get_temp get_temp=options.get_temp
get_fan=options.get_fan 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 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)): if (re.match('^file:', user) or re.match('^file:', password)):
@ -602,6 +610,14 @@ if cimport:
verboseoutput("Using manually defined CIM port "+cimport) verboseoutput("Using manually defined CIM port "+cimport)
hosturl += ':'+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 # connection to host
verboseoutput("Connection to "+hosturl) verboseoutput("Connection to "+hosturl)
# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently # pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
@ -788,7 +804,6 @@ for classe in ClassesToCheck :
verboseoutput(" Family = %d" % instance['Family']) verboseoutput(" Family = %d" % instance['Family'])
verboseoutput(" CurrentClockSpeed = %dMHz" % instance['CurrentClockSpeed']) verboseoutput(" CurrentClockSpeed = %dMHz" % instance['CurrentClockSpeed'])
# HP Check # HP Check
if vendor == "hp" : if vendor == "hp" :
if instance['HealthState'] is not None : if instance['HealthState'] is not None :
@ -804,11 +819,11 @@ for classe in ClassesToCheck :
30 : ExitCritical, # Non-recoverable Error 30 : ExitCritical, # Non-recoverable Error
}[elementStatus] }[elementStatus]
if (interpretStatus == ExitCritical) : if (interpretStatus == ExitCritical) :
verboseoutput("GLobal exit set to CRITICAL") verboseoutput("Global exit set to CRITICAL")
GlobalStatus = ExitCritical GlobalStatus = ExitCritical
ExitMsg += " CRITICAL : %s " % elementNameValue ExitMsg += " CRITICAL : %s " % elementNameValue
if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) : if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) :
verboseoutput("GLobal exit set to WARNING") verboseoutput("Global exit set to WARNING")
GlobalStatus = ExitWarning GlobalStatus = ExitWarning
ExitMsg += " WARNING : %s " % elementNameValue ExitMsg += " WARNING : %s " % elementNameValue
# Added the following for when GlobalStatus is ExitCritical and a warning is detected # Added the following for when GlobalStatus is ExitCritical and a warning is detected
@ -825,8 +840,6 @@ for classe in ClassesToCheck :
elif (vendor == "dell" or vendor == "intel" or vendor == "ibm" or vendor=="unknown") : elif (vendor == "dell" or vendor == "intel" or vendor == "ibm" or vendor=="unknown") :
# Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it # Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it
ignore_list.append("System Board 1 Riser Config Err 0: Connected") 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("Add-in Card 4 PEM Presence 0: Connected") ignore_list.append("Add-in Card 4 PEM Presence 0: Connected")
if instance['OperationalStatus'] is not None : if instance['OperationalStatus'] is not None :
elementStatus = instance['OperationalStatus'][0] elementStatus = instance['OperationalStatus'][0]
@ -859,7 +872,7 @@ for classe in ClassesToCheck :
GlobalStatus = ExitCritical GlobalStatus = ExitCritical
ExitMsg += " CRITICAL : %s " % elementNameValue ExitMsg += " CRITICAL : %s " % elementNameValue
if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) : if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) :
verboseoutput("GLobal exit set to WARNING") verboseoutput("Global exit set to WARNING")
GlobalStatus = ExitWarning GlobalStatus = ExitWarning
ExitMsg += " WARNING : %s " % elementNameValue ExitMsg += " WARNING : %s " % elementNameValue
# Added same logic as in 20100702 here, otherwise Dell servers would return UNKNOWN instead of OK # Added same logic as in 20100702 here, otherwise Dell servers would return UNKNOWN instead of OK