Module: check_mk
Branch: master
Commit: 646295da7824c5fa75e9f61381192181cb91fe7f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=646295da7824c5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 14 08:27:17 2018 +0100
5903 FIX Improved handling of CTRL+C in some situations
When performing longer interactive tasks, e.g. during checking, the
interrupt of users (CTRL+C) was not handled in a good way in some
prominent places.
Change-Id: I2d934cf9e2122dfdf2ba1d4ccd0088e1e7a81944
---
.werks/5903 | 12 ++++++++++++
bin/check_mk | 26 +++++++++++++-------------
cmk_base/checks.py | 8 +++++++-
cmk_base/data_sources/abstract.py | 6 +++++-
cmk_base/data_sources/tcp.py | 4 ++++
5 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/.werks/5903 b/.werks/5903
new file mode 100644
index 0000000..f23d0a6
--- /dev/null
+++ b/.werks/5903
@@ -0,0 +1,12 @@
+Title: Improved handling of CTRL+C in some situations
+Level: 1
+Component: core
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1521012379
+Class: fix
+
+When performing longer interactive tasks, e.g. during checking, the
+interrupt of users (CTRL+C) was not handled in a good way in some
+prominent places.
diff --git a/bin/check_mk b/bin/check_mk
index 3591bd7..f071448 100755
--- a/bin/check_mk
+++ b/bin/check_mk
@@ -75,20 +75,20 @@ except getopt.GetoptError, err:
# First load the general modifying options
modes.process_general_options(opts)
-# At least in case the config is needed, the checks are needed too, because
-# the configuration may refer to check config variable names.
-if len(set.intersection(set(modes.non_checks_options()),
- [o[0] for o in opts])) == 0:
- checks.load()
-
-# Read the configuration files (main.mk, autochecks, etc.), but not for
-# certain operation modes that does not need them and should not be harmed
-# by a broken configuration
-if len(set.intersection(set(modes.non_config_options()),
- [o[0] for o in opts])) == 0:
- config.load()
-
try:
+ # At least in case the config is needed, the checks are needed too, because
+ # the configuration may refer to check config variable names.
+ if len(set.intersection(set(modes.non_checks_options()),
+ [o[0] for o in opts])) == 0:
+ checks.load()
+
+ # Read the configuration files (main.mk, autochecks, etc.), but not for
+ # certain operation modes that does not need them and should not be harmed
+ # by a broken configuration
+ if len(set.intersection(set(modes.non_config_options()),
+ [o[0] for o in opts])) == 0:
+ config.load()
+
# Now find the requested mode and execute it
done, exit_status = False, 0
for o, a in opts:
diff --git a/cmk_base/checks.py b/cmk_base/checks.py
index f99fa80..134d6ec 100644
--- a/cmk_base/checks.py
+++ b/cmk_base/checks.py
@@ -31,7 +31,7 @@ import ast
from collections import OrderedDict
import cmk.paths
-from cmk.exceptions import MKGeneralException
+from cmk.exceptions import MKGeneralException, MKTerminate
import cmk_base
import cmk_base.utils
@@ -152,6 +152,9 @@ def load_checks(filelist):
execfile(f, check_context)
loaded_files.add(file_name)
+ except MKTerminate:
+ raise
+
except Exception, e:
console.error("Error in plugin file %s: %s\n", f, e)
if cmk.debug.enabled():
@@ -246,6 +249,9 @@ def load_check_includes(check_file_path, check_context):
include_file_path = check_include_file_path(include_file_name)
try:
execfile(include_file_path, check_context)
+ except MKTerminate:
+ raise
+
except Exception, e:
console.error("Error in check include file %s: %s\n",
include_file_path, e)
if cmk.debug.enabled():
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index 2fa932b..c30b54c 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -35,7 +35,7 @@ import cmk.paths
import cmk.store as store
import cmk.tty as tty
import cmk.cpu_tracking as cpu_tracking
-from cmk.exceptions import MKGeneralException
+from cmk.exceptions import MKGeneralException, MKTerminate
import cmk_base.utils
import cmk_base.console as console
@@ -135,6 +135,10 @@ class DataSource(object):
self._host_sections = host_sections
return host_sections
+
+ except MKTerminate:
+ raise
+
except Exception, e:
self._logger.verbose("ERROR: %s" % e)
if cmk.debug.enabled():
diff --git a/cmk_base/data_sources/tcp.py b/cmk_base/data_sources/tcp.py
index 2fe0a20..085fcc2 100644
--- a/cmk_base/data_sources/tcp.py
+++ b/cmk_base/data_sources/tcp.py
@@ -30,6 +30,7 @@ import socket
import subprocess
import cmk.debug
+from cmk.exceptions import MKTerminate
import cmk_base.console as console
import cmk_base.config as config
@@ -117,6 +118,9 @@ class TCPDataSource(CheckMKAgentDataSource):
output.append(data)
else:
break
+ except MKTerminate:
+ raise
+
except socket.error, e:
if cmk.debug.enabled():
raise