Module: check_mk
Branch: master
Commit: 42b2734ad1e48db0d8939f736818459ae4974ade
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42b2734ad1e48d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 2 13:48:49 2019 +0200
7239 FIX Service discovery: Fix creating disabled services rule for services with special characters
Services with e.g. "[" in their names could not be disabled using the service discovery page.
Change-Id: I592ee8757cc194f087a14842ea04548be5066666
---
.werks/7239 | 11 +++++++++++
cmk/gui/wato/pages/services.py | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/.werks/7239 b/.werks/7239
new file mode 100644
index 0000000..89070b1
--- /dev/null
+++ b/.werks/7239
@@ -0,0 +1,11 @@
+Title: Service discovery: Fix creating disabled services rule for services with special characters
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1552549690
+
+Services with e.g. "[" in their names could not be disabled using the service discovery page.
diff --git a/cmk/gui/wato/pages/services.py b/cmk/gui/wato/pages/services.py
index 5d97db7..e376c49 100644
--- a/cmk/gui/wato/pages/services.py
+++ b/cmk/gui/wato/pages/services.py
@@ -32,6 +32,7 @@ import traceback
import time
import pprint
import sys
+import re
from hashlib import sha256
from typing import NamedTuple, Text, List, Optional # pylint: disable=unused-import
@@ -787,7 +788,7 @@ class ModeAjaxServiceDiscovery(WatoWebApiMode):
return
def _compile_patterns(services):
- return ["%s$" % s.replace("\\", "\\\\") for s in services]
+ return ["%s$" % re.escape(s) for s in services]
rulesets = watolib.AllRulesets()
rulesets.load()
Module: check_mk
Branch: master
Commit: 0f51e513ba84d8688ccdb441c74ac59bb9c875dd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0f51e513ba84d8…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Apr 2 11:59:42 2019 +0200
mssql_blocked_sessions: Minor cleanup
Change-Id: Ia2c9296ce348a33d071f64908d116164470109db
---
checkman/mssql_blocked_sessions | 3 ---
checks/mssql_blocked_sessions | 16 +++++++++-------
.../wato/check_parameters/mssql_blocked_sessions.py | 4 +---
.../check_parameters/mssql_instance_blocked_sessions.py | 4 +---
4 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/checkman/mssql_blocked_sessions b/checkman/mssql_blocked_sessions
index 076f75d..76f8d64 100644
--- a/checkman/mssql_blocked_sessions
+++ b/checkman/mssql_blocked_sessions
@@ -11,9 +11,6 @@ description:
Alternatively you can configure thresholds for the SQL output
"wait_duration_ms".
- These two options can {not} be combined. If thresholds are set,
- they will have precedence.
-
This check needs the Check_MK mssql.vbs -plugin installed in
the agent. Please refer to the online documentation
for how to install that plugin.
diff --git a/checks/mssql_blocked_sessions b/checks/mssql_blocked_sessions
index 077ef55..aa9426a 100644
--- a/checks/mssql_blocked_sessions
+++ b/checks/mssql_blocked_sessions
@@ -80,25 +80,27 @@ def check_mssql_blocked_sessions(item, params, parsed):
ignored_waittypes.add(db_inst.wait_type)
continue
- level_info = ""
- state = 0
if crit is not None and db_inst.wait_duration >= crit:
state = 2
elif warn is not None and db_inst.wait_duration >= warn:
state = 1
- if state:
- level_info = " (warn/crit at %s/%s)" % (get_age_human_readable(warn),
- get_age_human_readable(crit))
+ else:
+ state = 0
summary.setdefault(db_inst.session_id, 0)
summary[db_inst.session_id] += 1
- details.append((state, "Session %s blocked by %s (Type: %s, Wait: %s)%s" % \
+ details.append((state, "Session %s blocked by %s (Type: %s, Wait: %s)" % \
(db_inst.session_id, db_inst.blocking_session_id, db_inst.wait_type,
- get_age_human_readable(db_inst.wait_duration), level_info)))
+ get_age_human_readable(db_inst.wait_duration))))
if summary:
yield params['state'], "Summary: %s" % (", ".join(
["%s blocked by %s ID(s)" % (k, v) for k, v in summary.iteritems()]))
+
+ max_state = max([state for state, _infotext in details])
+ if max_state:
+ yield max_state, 'At least one session above thresholds (warn/crit at %s/%s)' % (
+ get_age_human_readable(warn), get_age_human_readable(crit))
for state, infotext in details:
yield state, "\n%s" % infotext
diff --git a/cmk/gui/plugins/wato/check_parameters/mssql_blocked_sessions.py b/cmk/gui/plugins/wato/check_parameters/mssql_blocked_sessions.py
index b831436..ee825c0 100644
--- a/cmk/gui/plugins/wato/check_parameters/mssql_blocked_sessions.py
+++ b/cmk/gui/plugins/wato/check_parameters/mssql_blocked_sessions.py
@@ -477,9 +477,7 @@ class RulespecCheckgroupParametersMssqlBlockedSessions(CheckParameterRulespecWit
elements=[
("state",
MonitoringState(
- title=_("State of MSSQL Blocked Sessions is treated as"),
- help=_("The default state if there is at least one "
- "blocked session."),
+ title=_("State if at least one blocked session"),
default_value=2,
)),
("waittime",
diff --git a/cmk/gui/plugins/wato/check_parameters/mssql_instance_blocked_sessions.py b/cmk/gui/plugins/wato/check_parameters/mssql_instance_blocked_sessions.py
index 3182058..60f71d9 100644
--- a/cmk/gui/plugins/wato/check_parameters/mssql_instance_blocked_sessions.py
+++ b/cmk/gui/plugins/wato/check_parameters/mssql_instance_blocked_sessions.py
@@ -66,9 +66,7 @@ class RulespecCheckgroupParametersMssqlInstanceBlockedSessions(CheckParameterRul
elements=[
("state",
MonitoringState(
- title=_("State of MSSQL Blocked Sessions is treated as"),
- help=_("The default state if there is at least one "
- "blocked session."),
+ title=_("State if at least one blocked session"),
default_value=2,
)),
("waittime",