Module: check_mk
Branch: master
Commit: b31b62341f37f6ac0ae6819ed6a6dbce1b6d2d9a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b31b62341f37f6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 21 17:41:30 2016 +0200
3390 Events can now be cancelled by the syslog application
Event Console rules can now close the events they created by having
a specific syslog application in messages.
If the application of the message matches this regular expression
(case insensitive) and either no text to cancel is specified or
that text also matched, then events created by this rule will
automatically be cancelled (if host, facility and match groups match).
---
.werks/3390 | 15 +++++++++++++++
ChangeLog | 1 +
bin/mkeventd | 34 ++++++++++++++++++++++------------
web/plugins/wato/mkeventd.py | 15 ++++++++++++---
4 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/.werks/3390 b/.werks/3390
new file mode 100644
index 0000000..56c44ca
--- /dev/null
+++ b/.werks/3390
@@ -0,0 +1,15 @@
+Title: Events can now be cancelled by the syslog application
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.9i1
+Date: 1461253178
+Class: feature
+
+Event Console rules can now close the events they created by having
+a specific syslog application in messages.
+
+If the application of the message matches this regular expression
+(case insensitive) and either no text to cancel is specified or
+that text also matched, then events created by this rule will
+automatically be cancelled (if host, facility and match groups match).
diff --git a/ChangeLog b/ChangeLog
index b3ef07c..b83ba63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -325,6 +325,7 @@
* 2999 The contact name is now included in Event Console notifications...
* 3262 Event Console: bulk delete button for custom MIBs now available
* 3388 Event Console can now process SNMPv3 traps...
+ * 3390 Events can now be cancelled by the syslog application...
* 3058 FIX: Event Console is now allowing non loadable MIB modules on startup...
* 3097 FIX: mkeventd: fixed crash with non-descriptive error message if mibs couldn't be loaded
* 3335 FIX: Improved error handling when requested rule pack does not exist
diff --git a/bin/mkeventd b/bin/mkeventd
index e68dc12..2aeb09d 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -1892,7 +1892,8 @@ class EventServer:
self.hash_rule(rule)
if "match_facility" not in rule \
and "match_priority" not in rule \
- and "cancel_priority" not in rule:
+ and "cancel_priority" not in rule \
+ and "cancel_application" not in rule:
count_unspecific += 1
@@ -2138,15 +2139,22 @@ class EventServer:
log(" did not match, because timeperiod %s is not active" % rule["match_timeperiod"])
return False
- if "match_ok" in rule or "cancel_priority" in rule:
+ if "match_ok" in rule or "cancel_priority" in rule or "cancel_application" in rule:
if "cancel_priority" in rule:
up, lo = rule["cancel_priority"]
cp = event["priority"] >= lo and event["priority"] <= up
else:
cp = True
+ if "cancel_application" in rule:
+ cancel_by_application = match(rule.get("cancel_application"),
+ event["application"],
+ complete=False)
+ else:
+ cancel_by_application = True
+
match_groups = match(rule.get("match_ok", ""), event["text"], complete = False)
- if match_groups != False and cp:
+ if match_groups != False and cp and cancel_by_application:
if debug:
log(" found cancelling event")
if match_groups == True:
@@ -3194,15 +3202,17 @@ class EventStatus():
(event["id"], event["host"], host))
return False
- # The same for the application
- application = new_event["application"]
- if "set_application" in rule:
- application = replace_groups(rule["set_application"], application, match_groups)
- if event["application"] != application:
- if debug:
- log("Do not cancel event %d: application is not the same (%s != %s)" %
- (event["id"], event["application"], application))
- return False
+ # The same for the application. But in case there is cancelling based on the application
+ # configured in the rule, then don't check for tidfferent applications.
+ if "cancel_application" not in rule:
+ application = new_event["application"]
+ if "set_application" in rule:
+ application = replace_groups(rule["set_application"], application, match_groups)
+ if event["application"] != application:
+ if debug:
+ log("Do not cancel event %d: application is not the same (%s != %s)" %
+ (event["id"], event["application"], application))
+ return False
if event["facility"] != new_event["facility"]:
if debug:
diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py
index fd1fa8f..41df8d3 100644
--- a/web/plugins/wato/mkeventd.py
+++ b/web/plugins/wato/mkeventd.py
@@ -651,7 +651,7 @@ vs_mkeventd_rule = Dictionary(
title = _("Syslog priority to cancel event"),
help = _("If the priority of the event lies withing this range and either no text to cancel "
"is specified or that text also matched, then events created with this rule will "
- "automatically be cancelled (if host, application and match groups match)."),
+ "automatically be cancelled (if host, application, facility and match groups match)."),
orientation = "horizontal",
show_titles = False,
elements = [
@@ -660,6 +660,15 @@ vs_mkeventd_rule = Dictionary(
],
),
),
+ ( "cancel_application",
+ RegExpUnicode(
+ title = _("Syslog application to cancel event"),
+ help = _("If the application of the message matches this regular expression "
+ "(case insensitive) and either no text to cancel is specified or "
+ "that text also matched, then events created by this rule will "
+ "automatically be cancelled (if host, facility and match groups match)."),
+ ),
+ ),
( "invert_matching",
Checkbox(
title = _("Invert matching"),
@@ -743,11 +752,11 @@ vs_mkeventd_rule = Dictionary(
optional_keys = [ "delay", "livetime", "count", "expect", "match_priority", "match_priority",
"match_facility", "match_sl", "match_host", "match_ipaddress", "match_application", "match_timeperiod",
"set_text", "set_host", "set_application", "set_comment",
- "set_contact", "cancel_priority", "match_ok", "contact_groups", ],
+ "set_contact", "cancel_priority", "cancel_application", "match_ok", "contact_groups", ],
headers = [
( _("Rule Properties"), [ "id", "description", "comment", "docu_url", "disabled" ] ),
( _("Matching Criteria"), [ "match", "match_host", "match_ipaddress", "match_application", "match_priority", "match_facility",
- "match_sl", "match_ok", "cancel_priority", "match_timeperiod", "invert_matching" ]),
+ "match_sl", "match_ok", "cancel_priority", "cancel_application", "match_timeperiod", "invert_matching" ]),
( _("Outcome & Action"), [ "state", "sl", "contact_groups", "actions", "cancel_actions", "cancel_action_phases", "drop", "autodelete" ]),
( _("Counting & Timing"), [ "count", "expect", "delay", "livetime", ]),
( _("Rewriting"), [ "set_text", "set_host", "set_application", "set_comment", "set_contact" ]),
Module: check_mk
Branch: master
Commit: 3184460a0216e9017649a538f6fdbc8021d4cf78
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3184460a0216e9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 21 16:57:50 2016 +0200
3389 FIX ps: Fixed stripped command lines for process checking on solaris systems
---
.werks/3389 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 23 +++++++++++++++++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/.werks/3389 b/.werks/3389
new file mode 100644
index 0000000..26f9987
--- /dev/null
+++ b/.werks/3389
@@ -0,0 +1,10 @@
+Title: ps: Fixed stripped command lines for process checking on solaris systems
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461250626
+
+
diff --git a/ChangeLog b/ChangeLog
index 29b051d..ebb8499 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -167,6 +167,7 @@
* 3387 FIX: ps: Fixed crash during service discovery on AIX hosts having defunct processes
* 3417 FIX: wmi_cpuload: fix exception in case of missing NumberOfLogicalProcessors on some OS versions
* 3124 FIX: workaround for overrunnig counters in a couple of wmi checks...
+ * 3389 FIX: ps: Fixed stripped command lines for process checking on solaris systems
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index da5b85c..d251723 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -189,8 +189,27 @@ fi
# Processes
echo '<<<ps>>>'
-ps -o user,vsz,rss,pcpu,args $pszone | \
-sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4) /'
+# The default solaris ps command strips the command lines of the processes. But for good process
+# matching on the server we really need to whole command line. On linux there are arguments to
+# make ps output the whole command line, but on solaris this seems to be missing. We use the ucb
+# ps command to get the full command line instead. What a hack.
+UCB_PS=$(/usr/ucb/ps -agwwwx)
+PS=$(ps -o user,vsz,rss,pcpu,etime,pid,args $pszone | \
+ sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4,\5,\6) /')
+while read -r LINE; do
+ STATS=${LINE%) *}
+ PID=${STATS##*,}
+
+ CMD=$(echo "$UCB_PS" | grep "\s*$PID " | head -n1 | \
+ awk '{ s = ""; for (i = 5; i <= NF; i++) s = s $i " "; print s }')
+ # Only use the ucb ps line when it's not empty (process might already been gone) and the
+ # ps line is long enough the be potentially stripped.
+ if [ -z "$CMD" ] || [ ${#LINE} -lt 100 ]; then
+ echo "$LINE"
+ else
+ echo "${STATS}) ${CMD}"
+ fi
+done <<< "$PS"
# Statgrab