Module: check_mk
Branch: master
Commit: 7f25de14d9033617416211dd489f760eab9162e8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f25de14d90336…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Sep 29 09:15:33 2014 +0200
#1408 FIX mknotifyd now really reads all configuration files below mknotifyd.d
Previously the notification spooler daemon <tt>mknotifyd</tt> just read the
single file <tt>etc/check_mk/mknotifyd.d/wato/global.mk</tt>. Now it reads
all files below <tt>etc/check_mk/mknotifyd.d</tt> - just as one would
expect. Note: there is still no <tt>etc/check_mk/mknotifyd.mk</tt> file.
---
.werks/1408 | 12 ++++++++++++
ChangeLog | 1 +
doc/treasures/mknotifyd | 26 ++++++++++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/.werks/1408 b/.werks/1408
new file mode 100644
index 0000000..fa7fc02
--- /dev/null
+++ b/.werks/1408
@@ -0,0 +1,12 @@
+Title: mknotifyd now really reads all configuration files below mknotifyd.d
+Level: 2
+Component: notifications
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411974839
+Class: fix
+
+Previously the notification spooler daemon <tt>mknotifyd</tt> just read the
+single file <tt>etc/check_mk/mknotifyd.d/wato/global.mk</tt>. Now it reads
+all files below <tt>etc/check_mk/mknotifyd.d</tt> - just as one would
+expect. Note: there is still no <tt>etc/check_mk/mknotifyd.mk</tt> file.
diff --git a/ChangeLog b/ChangeLog
index 1ab5d69..4795829 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -136,6 +136,7 @@
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no sendsms/smssend)...
* 1407 FIX: Fix exception in rule based notification on non-Ascii characters in log message
+ * 1408 FIX: mknotifyd now really reads all configuration files below mknotifyd.d...
BI:
* 1406 Assume PEND in count_ok aggregations if all nodes are PEND...
diff --git a/doc/treasures/mknotifyd b/doc/treasures/mknotifyd
index 44cca4c..0a793d8 100755
--- a/doc/treasures/mknotifyd
+++ b/doc/treasures/mknotifyd
@@ -352,9 +352,16 @@ def daemonize(user=0, group=0):
def load_configuration():
global g_config, g_config_changed
last_config = g_config.copy()
- config_file = "%s/mknotifyd.d/wato/global.mk" % g_config_dir
+ config_dir = "%s/mknotifyd.d" % g_config_dir
+
try:
- execfile(config_file, {}, g_config)
+ list_of_files = reduce(lambda a,b: a+b,
+ [ [ "%s/%s" % (d, f) for f in fs if f.endswith(".mk")]
+ for d, sb, fs in os.walk(config_dir) ], [])
+ list_of_files.sort(cmp = cmp_config_paths)
+ for path in list_of_files:
+ verbose("Reading configuration file %s" % path)
+ execfile(path, {}, g_config)
except:
g_config = last_config
@@ -362,6 +369,21 @@ def load_configuration():
log("Configuration has changed")
g_config_changed = True
+# This function has been stolen from check_mk.py.
+# Helper function that determines the sort order of the
+# configuration files. The following two rules are implemented:
+# 1. *.mk files in the same directory will be read
+# according to their lexical order.
+# 2. subdirectories in the same directory will be
+# scanned according to their lexical order.
+# 3. subdirectories of a directory will always be read *after*
+# the *.mk files in that directory.
+def cmp_config_paths(a, b):
+ pa = a.split('/')
+ pb = b.split('/')
+ return cmp(pa[:-1], pb[:-1]) or \
+ cmp(len(pa), len(pb)) or \
+ cmp(pa, pb)
def usage():
sys.stdout.write("""Usage: mknotifyd [OPTIONS]
Module: check_mk
Branch: master
Commit: e1570af4e0e82cdcefb4c7356c62f09527baab57
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e1570af4e0e82c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Sep 26 12:23:56 2014 +0200
#1407 FIX Fix exception in rule based notification on non-Ascii characters in log message
---
.werks/1407 | 9 +++++++++
ChangeLog | 1 +
modules/notify.py | 4 ++--
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.werks/1407 b/.werks/1407
new file mode 100644
index 0000000..90bf678
--- /dev/null
+++ b/.werks/1407
@@ -0,0 +1,9 @@
+Title: Fix exception in rule based notification on non-Ascii characters in log message
+Level: 2
+Component: notifications
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411727016
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index ebf9490..1ab5d69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -135,6 +135,7 @@
* 1400 Added example notification script for Pushover to doc/treasures/notifications...
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no sendsms/smssend)...
+ * 1407 FIX: Fix exception in rule based notification on non-Ascii characters in log message
BI:
* 1406 Assume PEND in count_ok aggregations if all nodes are PEND...
diff --git a/modules/notify.py b/modules/notify.py
index 24e4c35..57b90d9 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1874,12 +1874,12 @@ def core_notification_log(plugin, plugin_context):
log_message = "%s NOTIFICATION: %s;%s;%s;%s;%s" % (
what, contact, spec, state, plugin or "plain email", output)
if monitoring_core == "cmc":
- livestatus_send_command("LOG;" + log_message)
+ livestatus_send_command("LOG;" + log_message.encode("utf-8"))
else:
# Nagios and friends do not support logging via an
# external command. We write the files into a help file
# in var/check_mk/notify. If the users likes he can
# replace that file with a symbolic link to the nagios
# log file. But note: Nagios logging might not atomic.
- file(notification_core_log, "a").write("[%d] %s\n" % (time.time(), log_message))
+ file(notification_core_log, "a").write("[%d] %s\n" % (time.time(), log_message.encode("utf-8")))
Module: check_mk
Branch: master
Commit: 32ed15a3cc2237bde6fb7cbcc203890e76e8aa0a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=32ed15a3cc2237…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Sep 26 11:04:30 2014 +0200
#1406 Assume PEND in count_ok aggregations if all nodes are PEND
If you are using the BI aggregation function <tt>count_ok</tt> then nodes
with the state <tt>PEND</tt> (which essentially means unmonitored or not
present) are handled differently from now.
If <b>all</b> nodes are pending then the total state will also be pending.
If just some of the nodes are pending then they will not taken into account.
This is especially imported when doing availability computations on
BI aggregates.
---
.werks/1406 | 16 ++++++++++++++++
ChangeLog | 3 +++
web/htdocs/bi.py | 29 +++++++++++++++++++++++------
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/.werks/1406 b/.werks/1406
new file mode 100644
index 0000000..b645eb0
--- /dev/null
+++ b/.werks/1406
@@ -0,0 +1,16 @@
+Title: Assume PEND in count_ok aggregations if all nodes are PEND
+Level: 2
+Component: bi
+Compatible: compat
+Version: 1.2.5i6
+Date: 1411721844
+Class: feature
+
+If you are using the BI aggregation function <tt>count_ok</tt> then nodes
+with the state <tt>PEND</tt> (which essentially means unmonitored or not
+present) are handled differently from now.
+
+If <b>all</b> nodes are pending then the total state will also be pending.
+If just some of the nodes are pending then they will not taken into account.
+This is especially imported when doing availability computations on
+BI aggregates.
diff --git a/ChangeLog b/ChangeLog
index e7fe90d..ebf9490 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -136,6 +136,9 @@
* 1156 FIX: Graphs in HTML mails are now sent again where they where missing...
* 1157 FIX: Fixed SMS plugin on at least debian (distrs which have no sendsms/smssend)...
+ BI:
+ * 1406 Assume PEND in count_ok aggregations if all nodes are PEND...
+
Event Console:
* 1148 Allow execution of actions when cancelling events...
* 1395 Event Console can now create notifications via Check_MK RBN...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index a133aaf..9fcbac7 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1301,16 +1301,33 @@ def aggr_countok_convert(num, count):
def aggr_countok(nodes, needed_for_ok=2, needed_for_warn=1):
states = [ i[0]["state"] for i in nodes ]
- num_ok = len([s for s in states if s == 0 ])
+ num_ok = len([s for s in states if s == 0 ])
+ num_nonok = len([s for s in states if s > 0 ])
+ num_pending = len(states) - num_ok - num_nonok
+ num_nodes = num_ok + num_nonok
+
+ # We need to handle the special case "PENDING" separately.
+ # Example: count is set to 50%. You have 10 nodes, all of
+ # which are PENDING, then the outcome must be PENDING, not
+ # CRIT.
+ if num_nodes == 0: # All are pending
+ return { "state": -1, "output": "" }
# counts can be specified as integer (e.g. '2') or
# as percentages (e.g. '70%').
- if num_ok >= aggr_countok_convert(needed_for_ok, len(states)):
- return { "state" : 0, "output" : "" }
- elif num_ok >= aggr_countok_convert(needed_for_warn, len(states)):
- return { "state" : 1, "output" : "" }
+ ok_count = aggr_countok_convert(needed_for_ok, num_nodes)
+ warn_count = aggr_countok_convert(needed_for_warn, num_nodes)
+
+ # Enough nodes are OK -> state is OK
+ if num_ok >= ok_count:
+ return { "state": 0, "output": "" }
+
+ # Enough nodes OK in order to trigger warn level -> WARN
+ elif num_ok >= warn_count:
+ return { "state": 1, "output": "" }
+
else:
- return { "state" : 2, "output" : "" }
+ return { "state": 2, "output": "" }
config.aggregation_functions["count_ok"] = aggr_countok