Module: check_mk
Branch: master
Commit: 9aa3eeccb436dc17d9007054c519b52910da2073
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9aa3eeccb436dc…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Dec 18 14:56:44 2015 +0100
#2821 FIX WATO rule based notifications: Validate regular expression for service conditions
The rule based notification conditions <i>Match only the following services</i> and
<i>Exclude the following services<i> were unabled to detect invalid regular expression.
An invalid regular expression causes an exception during the notification processing,
which ultimately leads to the loss of any notification running through this broken rule.
---
.werks/2821 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 4 ++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/.werks/2821 b/.werks/2821
new file mode 100644
index 0000000..9deee50
--- /dev/null
+++ b/.werks/2821
@@ -0,0 +1,13 @@
+Title: WATO rule based notifications: Validate regular expression for service conditions
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.2.7i4
+Date: 1450446173
+Class: fix
+
+The rule based notification conditions <i>Match only the following services</i> and
+<i>Exclude the following services<i> were unabled to detect invalid regular expression.
+
+An invalid regular expression causes an exception during the notification processing,
+which ultimately leads to the loss of any notification running through this broken rule.
diff --git a/ChangeLog b/ChangeLog
index 5aacd49..dcf7160 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -226,6 +226,7 @@
* 2728 FIX: Removed debug notification script (was not executable)...
* 2843 FIX: Hanging notification scripts could prevent all other notifications...
* 2815 FIX: Notification scripts: Fixed missing environment variables...
+ * 2821 FIX: WATO rule based notifications: Validate regular expression for service conditions...
Event Console:
* 2733 Visibility of Event Console events more flexible now...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 7040032..14202cc 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7007,7 +7007,7 @@ def generic_rule_match_conditions():
help = _("Specify a list of regular expressions that must match the <b>beginning</b> of the "
"service name in order for the rule to match. Note: Host notifications never match this "
"rule if this option is being used."),
- valuespec = TextUnicode(size = 32),
+ valuespec = RegExpUnicode(size = 32),
orientation = "horizontal",
allow_empty = False,
empty_text = _("Please specify at least one service regex. Disable the option if you want to allow all services."),
@@ -7016,7 +7016,7 @@ def generic_rule_match_conditions():
( "match_exclude_services",
ListOfStrings(
title = _("Exclude the following services"),
- valuespec = TextUnicode(size = 32),
+ valuespec = RegExpUnicode(size = 32),
orientation = "horizontal",
)
),
Module: check_mk
Branch: master
Commit: 7647cd04fdb096c825559e3ac22d4ca2294243b5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7647cd04fdb096…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Dec 18 11:35:03 2015 +0100
#2881 Automatically restart core instead of reload after changes in local check plugins
If you create, remove or modify you own check plugins in
<tt>~/local/share/check_mk/checks</tt> then usually had to do a real core
restart with <tt>cmk -R</tt> in order to activate these changes. This is now
done automatically. Whenever you do <i>Activate Changes</i> then Check_MK
does a real restart on demand if it sees any modification in the check plugins.
This also helps the handling of installing and removing Check_MK packages (MKPs).
---
.werks/2881 | 14 ++++++++++++++
ChangeLog | 1 +
modules/automation.py | 30 ++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
diff --git a/.werks/2881 b/.werks/2881
new file mode 100644
index 0000000..575e104
--- /dev/null
+++ b/.werks/2881
@@ -0,0 +1,14 @@
+Title: Automatically restart core instead of reload after changes in local check plugins
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.7i4
+Date: 1450434659
+Class: feature
+
+If you create, remove or modify you own check plugins in
+<tt>~/local/share/check_mk/checks</tt> then usually had to do a real core
+restart with <tt>cmk -R</tt> in order to activate these changes. This is now
+done automatically. Whenever you do <i>Activate Changes</i> then Check_MK
+does a real restart on demand if it sees any modification in the check plugins.
+This also helps the handling of installing and removing Check_MK packages (MKPs).
diff --git a/ChangeLog b/ChangeLog
index 31514d7..5aacd49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.2.7i4:
Core & Setup:
* 2771 Errors in Check_MK configuration do not prevent the core from being restarted anymore...
+ * 2881 Automatically restart core instead of reload after changes in local check plugins...
* 2682 FIX: Fixed exception Error creating configuration: global name 'extra_host_attributes' is not defined
* 2443 FIX: Fixed quoting of ! in classical nagios checks configured via WATO...
* 2718 FIX: Fixed agent timeouts not resulting in a crash report anympore...
diff --git a/modules/automation.py b/modules/automation.py
index 8622454..e76ec10 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -412,6 +412,8 @@ def automation_delete_host(args):
def automation_restart(job = "restart", use_rushd = True):
+ if job == "reload" and check_plugins_have_changed():
+ job = "restart"
# make sure, Nagios does not inherit any open
# filedescriptors. This really happens, e.g. if
@@ -492,6 +494,34 @@ def automation_restart(job = "restart", use_rushd = True):
sys.stdout = old_stdout
return configuration_warnings
+
+def check_plugins_have_changed():
+ if not omd_root:
+ return False # not supported for manual setup
+
+ this_time = last_modification_in_dir(local_checks_dir)
+ last_time = time_of_last_config_creation()
+ return this_time > last_time
+
+
+def last_modification_in_dir(dir_path):
+ max_time = os.stat(dir_path).st_mtime
+ for file_name in os.listdir(dir_path):
+ max_time = max(max_time, os.stat(dir_path + "/" + file_name).st_mtime)
+ return max_time
+
+
+def time_of_last_config_creation():
+ if monitoring_core == "cmc":
+ config_path = omd_root + "/var/check_mk/core/config"
+ else:
+ config_path = omd_root + "/etc/nagios/conf.d/check_mk_objects.cfg"
+ if os.path.exists(config_path):
+ return os.stat(config_path).st_mtime
+ else:
+ return 0
+
+
def automation_get_configuration():
# We read the list of variable names from stdin since
# that could be too much for the command line