Module: check_mk
Branch: master
Commit: ffc64631910856094c2a06bba6087fc48b97a93a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ffc64631910856…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 25 12:18:50 2016 +0200
3610 mk_oracle: linux plugin now available for solaris
---
.werks/3610 | 9 +++++++
ChangeLog | 1 +
agents/plugins/mk_oracle | 62 ++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 67 insertions(+), 5 deletions(-)
diff --git a/.werks/3610 b/.werks/3610
new file mode 100644
index 0000000..acebd42
--- /dev/null
+++ b/.werks/3610
@@ -0,0 +1,9 @@
+Title: mk_oracle: linux plugin now available for solaris
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1464171502
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index fe153e1..0094e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -85,6 +85,7 @@
* 3609 apc_rackpdu_power: now upper levels for electrical current are confiugurable
* 3136 windows agent: improved crash reporting...
* 3137 linux and solaris agent: mrpe checks now support option to append the cache age to cached results...
+ * 3610 mk_oracle: linux plugin now available for solaris
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index db93083..cfcee92 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -677,6 +677,49 @@ sql_asm_diskgroup()
}
#.
+# .--set_osenv-----------------------------------------------------------.
+# | _ |
+# | ___ ___| |_ ___ ___ ___ _ ____ __ |
+# | / __|/ _ \ __| / _ \/ __|/ _ \ '_ \ \ / / |
+# | \__ \ __/ |_ | (_) \__ \ __/ | | \ V / |
+# | |___/\___|\__|___\___/|___/\___|_| |_|\_/ |
+# | |_____| |
+# +----------------------------------------------------------------------+
+# | Functions for Operating System dependent stuff |
+# '----------------------------------------------------------------------'
+
+function set_osenv () {
+ ostype=$(uname -s)
+
+ if [ ${ostype} = 'Linux' ] ; then
+
+ GREP=$(which grep)
+ STATCX='stat -c %X'
+ STATCY='stat -c %Y'
+
+ elif [ ${ostype} = 'SunOS' ] ; then
+
+ # expand the PATH for inetd. Otherwise some stuff in /opt/sfw/bin is not found!
+ export PATH=$PATH:/usr/ucb:/usr/proc/bin:opt/sfw/bin:/opt/sfw/sbin:/usr/sfw/bin:/usr/sfw/sbin:/opt/csw/bin
+
+ GREP=/usr/xpg4/bin/grep
+
+ if [ ! -x $GREP ] ; then
+ echo "Please make sure that "$GREP" is existing on Solaris!"
+ echo "Aborting mk_oracle plugin."
+ exit 999
+ fi
+
+ STATCX='file_mtime'
+ STATCY='file_mtime'
+
+ else
+ ostype="unknown OS: "${ostype}
+ fi
+
+}
+
+#.
# .--oraenv--------------------------------------------------------------.
# | |
# | ___ _ __ __ _ ___ _ ____ __ |
@@ -1005,6 +1048,10 @@ export -f ora_session_environment
export -f do_async_checks
export -f set_oraenv
+function file_mtime() {
+ /usr/bin/perl -e 'if (! -f $ARGV[0]){die "0000000"};$mtime=(stat($ARGV[0]))[9];print ($mtime);' "$1"
+}
+
function run_cached () {
local section=
if [ "$1" = -s ] ; then local section="echo '<<<$2>>>' ; " ; shift ; fi
@@ -1018,9 +1065,10 @@ function run_cached () {
# Check if the creation of the cache takes suspiciously long and return
# nothing if the age (access time) of $CACHEFILE.new is twice the MAXAGE
- local NOW=$(date +%s)
+ # perl is needed for Solaris => no date +%s availible
+ local NOW=$(perl -le "print time()")
if [ -e "$CACHEFILE.new" ] ; then
- local CF_ATIME=$(stat -c %X "$CACHEFILE.new")
+ local CF_ATIME=$($STATCX "$CACHEFILE.new")
if [ $((NOW - CF_ATIME)) -ge $((MAXAGE * 2)) ] ; then
# Kill the process still accessing that file in case
# it is still running. This avoids overlapping processes!
@@ -1032,7 +1080,7 @@ function run_cached () {
# Check if cache file exists and is recent enough
if [ -s "$CACHEFILE" ] ; then
- local MTIME=$(stat -c %Y "$CACHEFILE")
+ local MTIME=$($STATCY "$CACHEFILE")
if [ $((NOW - MTIME)) -le $MAXAGE ] ; then local USE_CACHEFILE=1 ; fi
# Output the file in any case, even if it is
# outdated. The new file will not yet be available
@@ -1052,6 +1100,7 @@ function run_cached () {
function do_testmode() {
echo "-----------------------------------------------"
+ echo "Operating System: "${ostype}
echo "Logincheck to Instance: "$SID" Version: "$ORACLE_VERSION
echo "select 'Login ok User: ' || user || ' on ' || host_name ||' Instance ' || instance_name
from v\$instance;" | sqlplus $SID
@@ -1113,8 +1162,11 @@ function do_instance() {
# | Iterate over all instances and execute sync and async sections. |
# '----------------------------------------------------------------------'
+# set some basic operating system stuff
+set_osenv
+
# Are there any remote configurations?
-for element in $(compgen -A variable | grep -E "^REMOTE_INSTANCE_.*") ; do
+for element in $(compgen -A variable | ${GREP} -E "^REMOTE_INSTANCE_.*") ; do
REMOTE_DBS=$REMOTE_DBS" "$element
@@ -1148,7 +1200,7 @@ fi
# Get list of all running databases
# Do not work on ASM in this plugin. => Ignore a running ASM-Instance!
-SIDS=$(UNIX95=true ps -ef | awk '{print $NF}' | grep -E '^asm_pmon_|^ora_pmon_|^xe_pmon_XE' | cut -d"_" -f3-)
+SIDS=$(UNIX95=true ps -ef | awk '{print $NF}' | ${GREP} -E '^asm_pmon_|^ora_pmon_|^xe_pmon_XE' | cut -d"_" -f3-)
# If we do not have found any running database instance, then either
# no ORACLE is present on this system or it's just currently not running.
Module: check_mk
Branch: master
Commit: 5fe65e00863e43c160e08224b71d7de49eefc29d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5fe65e00863e43…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed May 25 12:09:15 2016 +0200
update for WK3532
---
modules/events.py | 26 ++++++++++++++++----------
web/htdocs/wato.py | 46 ++++++++++++++++++++++++++++++++++------------
2 files changed, 50 insertions(+), 22 deletions(-)
diff --git a/modules/events.py b/modules/events.py
index d6a9c13..8d261c9 100644
--- a/modules/events.py
+++ b/modules/events.py
@@ -336,7 +336,7 @@ def event_match_hosttags(rule, context):
def event_match_servicegroups(rule, context, is_regex = False):
if is_regex:
- required_groups = rule.get("match_servicegroups_regex")
+ match_type, required_groups = rule.get("match_servicegroups_regex", (None, None))
else:
required_groups = rule.get("match_servicegroups")
@@ -361,23 +361,27 @@ def event_match_servicegroups(rule, context, is_regex = False):
if is_regex:
r = regex(group)
for sg in servicegroups:
- # The regex must match the alias name!
- if r.search(define_servicegroups[sg]):
+ match_value = match_type == "match_alias" and define_servicegroups[sg] or sg
+ if r.search(match_value):
return
elif group in servicegroups:
return
if is_regex:
- return "The service is only in the groups %s. None of these patterns match: %s" % (
- '"' + '", "'.join(map(lambda x: define_servicegroups[x], servicegroups)) + '"',
- '"' + '" or "'.join(required_groups)) + '"'
+ if match_type == "match_alias":
+ return "The service is only in the groups %s. None of these patterns match: %s" % (
+ '"' + '", "'.join(map(lambda x: define_servicegroups[x], servicegroups)) + '"',
+ '"' + '" or "'.join(required_groups)) + '"'
+ else:
+ return "The service is only in the groups %s. None of these patterns match: %s" % (
+ '"' + '", "'.join(servicegroups) + '"', '"' + '" or "'.join(required_groups)) + '"'
else:
return "The service is only in the groups %s, but %s is required" % (
sgn, " or ".join(required_groups))
def event_match_exclude_servicegroups(rule, context, is_regex = False):
if is_regex:
- excluded_groups = rule.get("match_exclude_servicegroups_regex")
+ match_type, excluded_groups = rule.get("match_exclude_servicegroups_regex", (None, None))
else:
excluded_groups = rule.get("match_exclude_servicegroups")
@@ -397,10 +401,12 @@ def event_match_exclude_servicegroups(rule, context, is_regex = False):
if is_regex:
r = regex(group)
for sg in servicegroups:
- # The regex must match the alias name!
- if r.search(define_servicegroups[sg]):
+ match_value = match_type == "match_alias" and define_servicegroups[sg] or sg
+ match_value_inverse = match_type == "match_alias" and sg or define_servicegroups[sg]
+
+ if r.search(match_value):
return "The service group \"%s\" (%s) is excluded per regex pattern: %s" %\
- (define_servicegroups[sg], sg, group)
+ (match_value, match_value_inverse, group)
elif group in servicegroups:
return "The service group %s is excluded" % group
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 92ef291..8ce203a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7301,21 +7301,43 @@ def generic_rule_match_conditions():
)
),
( "match_servicegroups_regex",
- ListOfStrings(
- title = _("Match Service Groups (regex)"),
- help = _("The service group alias must match one of the following regular expressions."
- " For host events this condition never matches as soon as at least one group is selected."),
- valuespec = RegExpUnicode(size = 32),
- orientation = "horizontal",
+ Tuple(
+ title = _("Match Service Groups (regex)"),
+ elements = [
+ DropdownChoice(
+ choices = [
+ ( "match_id", _("Match the internal identifier")),
+ ( "match_alias", _("Match the alias"))
+ ],
+ default = "match_id"
+ ),
+ ListOfStrings(
+ help = _("The service group alias must match one of the following regular expressions."
+ " For host events this condition never matches as soon as at least one group is selected."),
+ valuespec = RegExpUnicode(size = 32),
+ orientation = "horizontal",
+ )
+ ]
)
),
( "match_exclude_servicegroups_regex",
- ListOfStrings(
- title = _("Exclude Service Groups (regex)"),
- help = _("The service group alias must not match one of the following regular expressions. "
- "For host events this condition is simply ignored."),
- valuespec = RegExpUnicode(size = 32),
- orientation = "horizontal",
+ Tuple(
+ title = _("Exclude Service Groups (regex)"),
+ elements = [
+ DropdownChoice(
+ choices = [
+ ( "match_id", _("Match the internal identifier")),
+ ( "match_alias", _("Match the alias"))
+ ],
+ default = "match_id"
+ ),
+ ListOfStrings(
+ help = _("The service group alias must not match one of the following regular expressions. "
+ "For host events this condition is simply ignored."),
+ valuespec = RegExpUnicode(size = 32),
+ orientation = "horizontal",
+ )
+ ]
)
),
( "match_services",
Module: check_mk
Branch: master
Commit: 23fcc184fc1454926d9589bd9795a62c8b5d50f6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=23fcc184fc1454…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 25 10:22:36 2016 +0200
3577 FIX Solaris agent: Fixed performance issue introduced with #3389
---
.werks/3577 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 11 ++++++++---
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/.werks/3577 b/.werks/3577
new file mode 100644
index 0000000..29ad630
--- /dev/null
+++ b/.werks/3577
@@ -0,0 +1,10 @@
+Title: Solaris agent: Fixed performance issue introduced with #3389
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1464164530
+
+
diff --git a/ChangeLog b/ChangeLog
index 1ab73e7..fe153e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -232,6 +232,7 @@
* 3605 FIX: kemp_loadmaster_ha, kemp_loadmaster_realserver, kemp_loadmaster_services: fixed discovery if data is wrong or incomplete
* 3607 FIX: wut_webtherm: fixed missing sensor data if only decimal comma marked values are available
* 3613 FIX: Fix vertical scaling of graph for disk utilization from 0...1% to 0...100%
+ * 3577 FIX: Solaris agent: Fixed performance issue introduced with #3389
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 17ce30e..420d0e7 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -211,11 +211,16 @@ if [ -x /usr/ucb/ps ]; then
STATS=${LINE%) *}
PID=${STATS##*,}
+ # Directly use ps output when line is too slow to be stripped
+ if [ ${#LINE} -lt 100 ]; then
+ echo "$LINE"
+ continue
+ fi
+
CMD=$(echo "$UCB_PS" | grep "^[ ]*$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
+ # Only use the ucb ps line when it's not empty (process might already been gone)
+ if [ -z "$CMD" ]; then
echo "$LINE"
else
echo "${STATS}) ${CMD}"
Module: check_mk
Branch: master
Commit: 2cb43705c565e50b4a4727cdbf94526b6ec6348c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2cb43705c565e5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 25 10:08:39 2016 +0200
3576 FIX LDAP: Fixed "Internal error" when using the "Filter Group" option in an LDAP connection
This exception occured when a user which is not in the group tried to log in to the GUI.
---
.werks/3576 | 10 +++++++
ChangeLog | 1 +
web/plugins/userdb/ldap.py | 71 +++++++++++++++++++++++++++++---------------
3 files changed, 58 insertions(+), 24 deletions(-)
diff --git a/.werks/3576 b/.werks/3576
new file mode 100644
index 0000000..a1774b2
--- /dev/null
+++ b/.werks/3576
@@ -0,0 +1,10 @@
+Title: LDAP: Fixed "Internal error" when using the "Filter Group" option in an LDAP connection
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1464163656
+
+This exception occured when a user which is not in the group tried to log in to the GUI.
diff --git a/ChangeLog b/ChangeLog
index e17841e..1ab73e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -307,6 +307,7 @@
* 3570 FIX: Dashboard: Fixed different issues with filtering using WATO folders
* 3571 FIX: Fixed missing downtime author filter
* 3537 FIX: PNP/Graph Templates: fixed incorrect scaling of check-mk-ping, check_mk-active-icmp and check-mk-host-ping...
+ * 3576 FIX: LDAP: Fixed "Internal error" when using the "Filter Group" option in an LDAP connection...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node selection...
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 54921ee..987438e 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -593,17 +593,37 @@ class LDAPUserConnector(UserConnector):
[user_id_attr],
self._config['user_scope']
)
- if result:
- dn = result[0][0]
- user_id = self.sanitize_user_id(result[0][1][user_id_attr][0])
- if user_id is None:
+
+ if not result:
+ return None
+
+ dn = result[0][0]
+ raw_user_id = result[0][1][user_id_attr][0]
+
+ # Filter out users by the optional filter_group
+ filter_group_dn = self._config.get('user_filter_group', None)
+ if filter_group_dn:
+ member_attr = self.member_attr().lower()
+ is_member = False
+ for member in self.get_filter_group_members(filter_group_dn):
+ if member_attr == "memberuid" and raw_user_id == member:
+ is_member = True
+ elif dn == member:
+ is_member = True
+
+ if not is_member:
return None
- self._user_cache[username] = (dn, user_id)
- if no_escape:
- return (dn, user_id)
- else:
- return (dn.replace('\\', '\\\\'), user_id)
+ user_id = self.sanitize_user_id(raw_user_id)
+ if user_id is None:
+ return None
+ self._user_cache[username] = (dn, user_id)
+
+ if no_escape:
+ return (dn, user_id)
+ else:
+ return (dn.replace('\\', '\\\\'), user_id)
+
def get_users(self, add_filter = ''):
@@ -617,7 +637,6 @@ class LDAPUserConnector(UserConnector):
# Create filter by the optional filter_group
filter_group_dn = self._config.get('user_filter_group', None)
- member_filter = ''
if filter_group_dn:
member_attr = self.member_attr().lower()
# posixGroup objects use the memberUid attribute to specify the group memberships.
@@ -625,21 +644,8 @@ class LDAPUserConnector(UserConnector):
# for filtering here.
user_cmp_attr = member_attr == 'memberuid' and user_id_attr or 'distinguishedname'
- # Apply configured group ldap filter
- try:
- group = self.ldap_search(self.replace_macros(filter_group_dn), columns=[member_attr], scope='base')
- except MKLDAPException:
- group = None
-
- if not group:
- raise MKLDAPException(_('The configured ldap user filter group could not be found. '
- 'Please check <a href="%s">your configuration</a>.') %
- 'wato.py?mode=ldap_config&varname=ldap_userspec')
-
- members = group[0][1].values()[0]
-
member_filter_items = []
- for member in members:
+ for member in self.get_filter_group_members(filter_group_dn):
member_filter_items.append('(%s=%s)' % (user_cmp_attr, member))
add_filter += '(|%s)' % ''.join(member_filter_items)
@@ -660,6 +666,23 @@ class LDAPUserConnector(UserConnector):
return result
+ # TODO: Use get_group_memberships()?
+ def get_filter_group_members(self, filter_group_dn):
+ member_attr = self.member_attr().lower()
+
+ try:
+ group = self.ldap_search(self.replace_macros(filter_group_dn), columns=[member_attr], scope='base')
+ except MKLDAPException:
+ group = None
+
+ if not group:
+ raise MKLDAPException(_('The configured ldap user filter group could not be found. '
+ 'Please check <a href="%s">your configuration</a>.') %
+ 'wato.py?mode=ldap_config&varname=ldap_userspec')
+
+ return [ m.lower() for m in group[0][1].values()[0] ]
+
+
def get_groups(self, specific_dn = None):
filt = self.ldap_filter('groups')
dn = self.replace_macros(self._config['group_dn'])
Module: check_mk
Branch: master
Commit: 93851e5c244cacf85a11f4f27a44312c7f318ca4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=93851e5c244cac…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 25 08:28:28 2016 +0200
Fixed non working event cancelling by syslog application
---
bin/mkeventd | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index 2e32c86..59c56f9 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -1849,7 +1849,8 @@ class EventServer:
self._rules.append(rule)
self._rule_by_id[rule["id"]] = rule
try:
- for key in [ "match", "match_ok", "match_host", "match_application" ]:
+ for key in [ "match", "match_ok", "match_host", "match_application",
+ "cancel_application" ]:
if key in rule:
value = compile_matching_value(key, rule[key])
if value == None:
@@ -1858,7 +1859,8 @@ class EventServer:
rule[key] = value
- if 'state' in rule and type(rule['state']) == tuple and rule['state'][0] == 'text_pattern':
+ if 'state' in rule and type(rule['state']) == tuple \
+ and rule['state'][0] == 'text_pattern':
for key in [ '2', '1', '0' ]:
if key in rule['state'][1]:
value = compile_matching_value('state', rule['state'][1][key])
@@ -2110,11 +2112,12 @@ class EventServer:
log(" did not match because of wrong source IP address '%s' (need '%s')" % (event["ipaddress"], rule.get("match_ipaddress")))
return False
- if False == match(rule.get("match_application"), event["application"], complete=False):
- if debug:
- log(" did not match because of wrong application '%s' (need '%s')" %
- (event["application"], pattern(rule.get("match_application"))))
- return False
+ if match(rule.get("match_application"), event["application"], complete=False) == False \
+ and "cancel_application" not in rule:
+ if debug:
+ log(" did not match because of wrong application '%s' (need '%s')" %
+ (event["application"], pattern(rule.get("match_application"))))
+ return False
if "match_facility" in rule and event["facility"] != rule["match_facility"]:
if debug:
@@ -2136,7 +2139,7 @@ class EventServer:
if "cancel_application" in rule:
cancel_by_application = match(rule.get("cancel_application"),
event["application"],
- complete=False)
+ complete=False) != False
else:
cancel_by_application = True