From e3a43a5dd0dfdf16ca6e63dda7a9008fe958adbc Mon Sep 17 00:00:00 2001 From: Stanislav German-Evtushenko Date: Mon, 16 Mar 2015 15:16:47 +0300 Subject: [PATCH 1/3] check_esxi_hardware.py: unknown instead of crit Set status to unknown instead of critical for timeouts, authentication errors and such things as those issues are critical for the check itself but not for the service. --- check_esxi_hardware.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 3a61754..876a026 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -565,8 +565,8 @@ if os_platform != "win32": on_windows = False import signal def handler(signum, frame): - print 'CRITICAL: Execution time too long!' - sys.exit(ExitCritical) + print 'UNKNOWN: Execution time too long!' + sys.exit(ExitUnknown) # connection to host verboseoutput("Connection to "+hosturl) @@ -619,13 +619,13 @@ for classe in ClassesToCheck : instance_list = wbemclient.EnumerateInstances(classe) except pywbem.cim_operations.CIMError,args: if ( args[1].find('Socket error') >= 0 ): - print "CRITICAL: %s" %args - sys.exit (ExitCritical) + print "UNKNOWN: %s" %args + sys.exit (ExitUnknown) else: verboseoutput("Unknown CIM Error: %s" % args) except pywbem.cim_http.AuthError,arg: verboseoutput("Global exit set to UNKNOWN") - GlobalStatus = ExitCritical + GlobalStatus = ExitUnknown print "UNKNOWN: Authentication Error" sys.exit (GlobalStatus) else: From b3c0ca4cdd91c6895f8600f5de3b9b9708bad10b Mon Sep 17 00:00:00 2001 From: Stanislav German-Evtushenko Date: Tue, 7 Apr 2015 15:56:00 +0300 Subject: [PATCH 2/3] check_esxi_hardware.py: force exit on timeout Replace sys.exit by os._exit to be sure that the script stops on timeout immediately and does not produce false-positive results (usually it comes to WARNING). --- check_esxi_hardware.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 876a026..6f816e7 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -223,6 +223,7 @@ import pywbem import re import string from optparse import OptionParser,OptionGroup +import os version = '20150119' @@ -566,7 +567,7 @@ if os_platform != "win32": import signal def handler(signum, frame): print 'UNKNOWN: Execution time too long!' - sys.exit(ExitUnknown) + os._exit(ExitUnknown) # connection to host verboseoutput("Connection to "+hosturl) From fb038edcda1c345ba439307e4b17a00e69b40a34 Mon Sep 17 00:00:00 2001 From: Stanislav German-Evtushenko Date: Mon, 1 Jun 2015 19:52:59 +0300 Subject: [PATCH 3/3] check_esxi_hardware.py: revert last change 1. This change was wrong and inappropriate. 2. The issue I tried to fix was caused by the bug in python library pywbem: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780264 --- check_esxi_hardware.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/check_esxi_hardware.py b/check_esxi_hardware.py index 6f816e7..876a026 100755 --- a/check_esxi_hardware.py +++ b/check_esxi_hardware.py @@ -223,7 +223,6 @@ import pywbem import re import string from optparse import OptionParser,OptionGroup -import os version = '20150119' @@ -567,7 +566,7 @@ if os_platform != "win32": import signal def handler(signum, frame): print 'UNKNOWN: Execution time too long!' - os._exit(ExitUnknown) + sys.exit(ExitUnknown) # connection to host verboseoutput("Connection to "+hosturl)