Module: check_mk
Branch: master
Commit: 7bda12dad35c9172a22316cd7e89b165f792ad31
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7bda12dad35c91…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 21 14:10:10 2013 +0200
keep alive mode alarm handling debugging
---
modules/check_mk_base.py | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 7d795fb..8225234 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -988,7 +988,7 @@ def do_check_keepalive():
def check_timeout(signum, frame):
raise MKCheckTimeout()
- signal.signal(signal.SIGALRM, check_timeout)
+ signal.signal(signal.SIGALRM, signal.SIG_IGN) # Prevent ALRM from CheckHelper.cc
global total_check_output
total_check_output = ""
@@ -1012,28 +1012,31 @@ def do_check_keepalive():
break
timeout = int(sys.stdin.readline())
- try:
- signal.alarm(timeout)
- if ';' in hostname:
- hostname, ipaddress = hostname.split(";", 1)
- elif hostname in ipaddress_cache:
- ipaddress = ipaddress_cache[hostname]
- else:
- if is_cluster(hostname):
- ipaddress = None
+ try: # catch non-timeout exceptions
+ try: # catch timeouts
+ signal.signal(signal.SIGALRM, check_timeout)
+ signal.alarm(timeout)
+ if ';' in hostname:
+ hostname, ipaddress = hostname.split(";", 1)
+ elif hostname in ipaddress_cache:
+ ipaddress = ipaddress_cache[hostname]
else:
- try:
- ipaddress = lookup_ipaddress(hostname)
- except:
- raise MKGeneralException("Cannot resolve hostname %s into IP
address" % hostname)
- ipaddress_cache[hostname] = ipaddress
+ if is_cluster(hostname):
+ ipaddress = None
+ else:
+ try:
+ ipaddress = lookup_ipaddress(hostname)
+ except:
+ raise MKGeneralException("Cannot resolve hostname %s
into IP address" % hostname)
+ ipaddress_cache[hostname] = ipaddress
- try:
status = do_check(hostname, ipaddress)
+ signal.signal(signal.SIGALRM, signal.SIG_IGN) # Prevent ALRM from
CheckHelper.cc
signal.alarm(0)
except MKCheckTimeout:
+ signal.signal(signal.SIGALRM, signal.SIG_IGN) # Prevent ALRM from
CheckHelper.cc
status = 3
- total_check_output = "UNKNOWN - Check_MK timed out after %d
seconds" % timeout
+ total_check_output = "UNKNOWN - Check_MK timed out after %d
seconds\n" % timeout
sys.stdout.write("%03d\n%08d\n%s" %
(status, len(total_check_output), total_check_output))
@@ -1058,6 +1061,7 @@ def do_check_keepalive():
sys.stdout.write("UNKNOWN - %s\n3\n" % e)
+
def check_unimplemented(checkname, params, info):
return (3, 'UNKNOWN - Check not implemented')