Module: check_mk
Branch: master
Commit: f017dc63308bc63914e5edfccfb56fec30d83f44
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f017dc63308bc6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 14 15:36:09 2016 +0100
Move some functions from notify.py to events.py
Reason: notify depends on events - not vice versa. But these functions
were called from events to notify.
Change-Id: I45877bbb4ba107181bc8d931ff8e8f205ecf683e
---
modules/events.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
modules/notify.py | 43 -------------------------------------------
2 files changed, 49 insertions(+), 43 deletions(-)
diff --git a/modules/events.py b/modules/events.py
index 0c4afa2..f81f5ba 100644
--- a/modules/events.py
+++ b/modules/events.py
@@ -186,6 +186,55 @@ def find_host_service_in_context(context):
else:
return host
+
+def livestatus_fetch_query(query):
+ # TODO: use livestatus.py instead!
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ sock.connect(cmk.paths.livestatus_unix_socket)
+ sock.send(query)
+ sock.shutdown(socket.SHUT_WR)
+ response = sock.recv(10000000)
+ sock.close()
+ return response
+
+
+def livestatus_fetch_contacts(host, service):
+ try:
+ if service:
+ query = "GET services\nFilter: host_name = %s\nFilter: service_description = %s\nColumns: contacts\n" % (
+ host, service)
+ else:
+ query = "GET hosts\nFilter: host_name = %s\nColumns: contacts\n" % host
+
+ commasepped = livestatus_fetch_query(query).strip()
+ aslist = commasepped.split(",")
+ if "check-mk-notify" in aslist: # Remove artifical contact used for rule based notifications
+ aslist.remove("check-mk-notify")
+ return ",".join(aslist)
+
+ except Exception, e:
+ if cmk.debug.enabled():
+ raise
+ return "" # We must allow notifications without Livestatus access
+
+
+
+
+def add_rulebased_macros(raw_context):
+ # For the rule based notifications we need the list of contacts
+ # an object has. The CMC does send this in the macro "CONTACTS"
+ if "CONTACTS" not in raw_context:
+ raw_context["CONTACTS"] = livestatus_fetch_contacts(raw_context["HOSTNAME"], raw_context.get("SERVICEDESC"))
+
+
+ # Add a pseudo contact name. This is needed for the correct creation
+ # of spool files. Spool files are created on a per-contact-base, as in classical
+ # notifications the core sends out one individual notification per contact.
+ # In the case of rule based notifications we do not make distinctions between
+ # the various contacts.
+ raw_context["CONTACTNAME"] = "check-mk-notify"
+
+
# Add a few further helper variables that are useful in notification and alert plugins
def complete_raw_context(raw_context, with_dump, event_log):
raw_keys = list(raw_context.keys())
diff --git a/modules/notify.py b/modules/notify.py
index 1e26a4e..e372475 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -508,19 +508,6 @@ def rbn_finalize_plugin_parameters(hostname, plugin, rule_parameters):
else:
return rule_parameters
-def add_rulebased_macros(raw_context):
- # For the rule based notifications we need the list of contacts
- # an object has. The CMC does send this in the macro "CONTACTS"
- if "CONTACTS" not in raw_context:
- raw_context["CONTACTS"] = livestatus_fetch_contacts(raw_context["HOSTNAME"], raw_context.get("SERVICEDESC"))
-
- # Add a pseudo contact name. This is needed for the correct creation
- # of spool files. Spool files are created on a per-contact-base, as in classical
- # notifications the core sends out one individual notification per contact.
- # In the case of rule based notifications we do not make distinctions between
- # the various contacts.
- raw_context["CONTACTNAME"] = "check-mk-notify"
-
# Create a table of all user specific notification rules. Important:
# create deterministic order, so that rule analyses can depend on
@@ -574,27 +561,6 @@ def rbn_add_contact_information(plugin_context, contact):
rbn_add_contact_information(plugin_context, contact_dict)
-def livestatus_fetch_contacts(host, service):
- try:
- if service:
- query = "GET services\nFilter: host_name = %s\nFilter: service_description = %s\nColumns: contacts\n" % (
- host, service)
- else:
- query = "GET hosts\nFilter: host_name = %s\nColumns: contacts\n" % host
-
- commasepped = livestatus_fetch_query(query).strip()
- aslist = commasepped.split(",")
- if "check-mk-notify" in aslist: # Remove artifical contact used for rule based notifications
- aslist.remove("check-mk-notify")
- return ",".join(aslist)
-
- except:
- if cmk.debug.enabled():
- raise
- return "" # We must allow notifications without Livestatus access
-
-
-
def rbn_match_rule(rule, context):
if rule.get("disabled"):
return "This rule is disabled"
@@ -1643,15 +1609,6 @@ def substitute_context(template, context):
# | Some generic helper functions |
# '----------------------------------------------------------------------'
-def livestatus_fetch_query(query):
- sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- sock.connect(cmk.paths.livestatus_unix_socket)
- sock.send(query)
- sock.shutdown(socket.SHUT_WR)
- response = sock.recv(10000000)
- sock.close()
- return response
-
def livestatus_send_command(command):
try:
message = "COMMAND [%d] %s\n" % (time.time(), command)
Module: check_mk
Branch: master
Commit: 7f68c468ccfae9337fe7f6c3b28f293d496aa972
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f68c468ccfae9…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Dec 14 10:15:41 2016 +0100
BI Aggregation: Added minor speedup in leaf node compilation
Change-Id: Ie7b8f2af39e174b58ea868bd1693e47757ffe718
---
web/htdocs/bi.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 45d938e..b4603e0 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -958,6 +958,10 @@ def match_host(hostname, hostalias, host_spec, tags, required_tags, site, honor_
def compile_leaf_node(host_re, service_re = config.HOST_STATE):
found = []
+
+ if host_re == "$1$":
+ return found
+
honor_site = SITE_SEP in host_re
if not honor_site and not '*' in host_re and not '$' in host_re \
and not '|' in host_re and '[' not in host_re:
Module: check_mk
Branch: master
Commit: f489fa87b164a9dc4eef8ecff361ce4751cd56e3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f489fa87b164a9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 14 12:59:57 2016 +0100
Add EC overflows to event console status table
Change-Id: I04d9d429dff01697b5e3e45330e033e9dbb3166b
---
livestatus/src/TableEventConsoleStatus.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/livestatus/src/TableEventConsoleStatus.cc b/livestatus/src/TableEventConsoleStatus.cc
index 3685e82..173cfda 100644
--- a/livestatus/src/TableEventConsoleStatus.cc
+++ b/livestatus/src/TableEventConsoleStatus.cc
@@ -68,6 +68,14 @@ TableEventConsoleStatus::TableEventConsoleStatus(MonitoringCore *mc)
addColumn(make_unique<DoubleEventConsoleColumn>("status_average_drop_rate",
"The average drop rate"));
addColumn(make_unique<IntEventConsoleColumn>(
+ "status_overflows",
+ "The number of message overflows, i.e. messages simply dropped due to "
+ "an overflow of the Event Console"));
+ addColumn(make_unique<DoubleEventConsoleColumn>("status_overflow_rate",
+ "The overflow rate"));
+ addColumn(make_unique<DoubleEventConsoleColumn>("status_average_overflow_rate",
+ "The average overflow rate"));
+ addColumn(make_unique<IntEventConsoleColumn>(
"status_events",
"The number of events received since startup of the Event Console"));
addColumn(make_unique<DoubleEventConsoleColumn>("status_event_rate",
Module: check_mk
Branch: master
Commit: b540c28b867c3c4b36f95e1116757f97caf2b1f6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b540c28b867c3c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 14 12:57:53 2016 +0100
EC: log overflows only in verbose mode, add counter for overflows
Change-Id: I30e48ba56a4ea0f506d170dfa4dfb47c402c339c
---
bin/mkeventd | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index 1cf41cf..ae28ce7 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -1036,6 +1036,7 @@ class Perfcounters:
"rule_tries" : 0,
"rule_hits" : 0,
"drops" : 0,
+ "overflows" : 0,
"events" : 0,
"connects" : 0,
}
@@ -2758,7 +2759,9 @@ class EventServer:
return False # Should have solved the issue. Hand over to next check.
if above_limit:
- log(" Skip processing because limit is in effect")
+ # Just log in verbose mode! Otherwise log file will be flooded
+ verbose(" Skip processing because limit is in effect")
+ g_perfcounters.count("overflows")
return True # Prevent creation and prevent one time actions (below)
log(" The limit has been reached")