Module: check_mk
Branch: master
Commit: 732c87d4bdcb7f68311740bd6470e249ec4d26b1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=732c87d4bdcb7f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Oct 11 11:42:36 2016 +0200
3956 fileinfo.groups: now allows regular expressions within include and exclude patterns each beginning with a tilde
---
.werks/3956 | 9 +++++++++
ChangeLog | 1 +
checks/fileinfo | 21 +++++++++++++++++----
web/plugins/wato/check_parameters.py | 6 ++++--
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/.werks/3956 b/.werks/3956
new file mode 100644
index 0000000..1d48cca
--- /dev/null
+++ b/.werks/3956
@@ -0,0 +1,9 @@
+Title: fileinfo.groups: now allows regular expressions within include and exclude patterns each beginning with a tilde
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476178717
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index b54045a..7b0cc4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
* 3913 gude_relayport, gude_temp, gude_humidity: new checks and relayport check now monitors electricity
* 3954 postfix_mailq_status: new check which monitors the status of postfix mail instances
* 3945 fortigate_node: Memory on fortigate clusters are now configurable by WATO...
+ * 3956 fileinfo.groups: now allows regular expressions within include and exclude patterns each beginning with a tilde
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
* 3907 FIX: oracle_tablespaces: simplyfied free space calculation depending on version...
* 3819 FIX: windows agent: fixed 2 bugs related to mrpe...
diff --git a/checks/fileinfo b/checks/fileinfo
index ff5201a..5d52695 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -73,17 +73,30 @@ def fileinfo_process_date(pattern, reftime):
return pattern
-def fileinfo_groups_of_file(check_filename,reftime):
+def fileinfo_groups_of_file(check_filename, reftime):
groups = []
for line in host_extra_conf(g_hostname, fileinfo_groups):
for group_name, pattern in line:
if type(pattern) == str: # support old format
pattern = ( pattern, '' )
+
inclusion, exclusion = pattern
- inclusion = fileinfo_process_date(inclusion,reftime)
- if fnmatch.fnmatch(check_filename, inclusion) \
- and not fnmatch.fnmatch(check_filename, exclusion):
+ if inclusion.startswith("~"):
+ reg = regex(inclusion[1:])
+ incl_match = reg.match( check_filename )
+ else:
+ inclusion = fileinfo_process_date(inclusion, reftime)
+ incl_match = fnmatch.fnmatch(check_filename, inclusion)
+
+ if exclusion.startswith("~"):
+ reg = regex(exlusion[1:])
+ excl_match = reg.match( check_filename )
+ else:
+ excl_match = fnmatch.fnmatch(check_filename, exclusion)
+
+ if incl_match and not excl_match:
groups.append(group_name)
+
return groups
def fileinfo_check_timeranges(params):
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index eba58d5..8aa8c29 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4300,7 +4300,9 @@ register_rule(group + '/' + subgroup_storage,
'not only for the total size and the age of the oldest/youngest '
'file but also on the count. You can define one or several '
'patterns for a group containing <tt>*</tt> and <tt>?</tt>, for example '
- '<tt>/var/log/apache/*.log</tt>. For files contained in a group '
+ '<tt>/var/log/apache/*.log</tt>. If the pattern begins with a tilde then '
+ 'this pattern is interpreted as a regular expression otherwise it is a '
+ 'glob. For files contained in a group '
'the discovery will automatically create a group service instead '
'of single services for each file. This rule also applies when '
'you use manually configured checks instead of inventorized ones. '
@@ -4314,7 +4316,7 @@ register_rule(group + '/' + subgroup_storage,
'The YESTERDAY syntax simply subtracts one day from the reference time.'),
valuespec = ListOf(
Tuple(
- help = _("This defines one file grouping pattern"),
+ help = _("This defines one file grouping pattern."),
show_titles = True,
orientation = "horizontal",
elements = [
Module: check_mk
Branch: master
Commit: 24a751df3a319299ae63c0170b7885947614d0ec
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=24a751df3a3192…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Oct 10 16:18:10 2016 +0200
Added todo
---
lib/paths.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/paths.py b/lib/paths.py
index 0a4bcfd..b84d44b 100644
--- a/lib/paths.py
+++ b/lib/paths.py
@@ -171,6 +171,9 @@ def _set_core_specific_paths():
})
+# TODO: Find a better way to determine the currently configured core.
+# For example generalize the etc/check_mk/conf.d/microcore.mk which is written by the CORE
+# hook -> Change the name to core.mk and write it for all configured cores.
def _get_core_name():
try:
for l in open(os.path.join(omd_root, "etc/omd/site.conf")):
Module: check_mk
Branch: master
Commit: ad1dac0ac09229e84cf8ae9f8c27974b5b2b4d60
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ad1dac0ac09229…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Oct 10 14:40:12 2016 +0200
3955 BI rule ID can now be renamed
---
.werks/3955 | 9 +++++++
ChangeLog | 3 +++
web/plugins/wato/bi.py | 66 ++++++++++++++++++++++++++++++++++++--------------
3 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/.werks/3955 b/.werks/3955
new file mode 100644
index 0000000..213bcc0
--- /dev/null
+++ b/.werks/3955
@@ -0,0 +1,9 @@
+Title: BI rule ID can now be renamed
+Level: 1
+Component: bi
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476103155
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index bfd956e..3250114 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,9 @@
* 3914 FIX: Roles: Aliases are now unique during cloning
* 3820 FIX: Network scan: no longer fails completely if hostname already exists in configuration...
+ BI:
+ * 3955 BI rule ID can now be renamed
+
Livestatus:
* 3740 Moved livedump utility from treasures directly into bin directory...
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index adb4ae0..2463647 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -1351,10 +1351,29 @@ class ModeBIEditRule(ModeBI):
def action(self):
self.must_be_contact_for_pack()
- if html.check_transaction():
- vs_rule = self.valuespec()
- new_rule = vs_rule.from_html_vars('rule')
- vs_rule.validate_value(new_rule, 'rule')
+
+ vs_rule = self.valuespec()
+ new_rule = vs_rule.from_html_vars('rule')
+ vs_rule.validate_value(new_rule, 'rule')
+
+ if self._ruleid and self._ruleid != new_rule["id"]:
+ existing_ruleid = self._ruleid
+ new_ruleid = new_rule["id"]
+ c = wato_confirm(_("Confirm renaming existing BI rule"),
+ _("Do you really want to rename the existing BI rule <b>%s</b> to <b>%s</b>?") % \
+ (existing_ruleid, new_ruleid))
+ if c:
+ self._ruleid = new_ruleid
+ del self._pack["rules"][existing_ruleid]
+ self._pack["rules"][new_ruleid] = new_rule
+ self._rename_existing_ruleid_after_confirm(existing_ruleid)
+ log_pending(SYNC, None, "bi-edit-rule", _("Renamed BI rule %s") % self._ruleid)
+ self.save_config()
+
+ else:
+ return False
+
+ elif html.check_transaction():
if self._new:
self._ruleid = new_rule["id"]
@@ -1365,6 +1384,7 @@ class ModeBIEditRule(ModeBI):
_("There is already a rule with the id <b>%s</b>. "
"It is in the pack <b>%s</b> and as the title <b>%s</b>") % (
self._ruleid, pack["title"], existing_rule["title"]))
+
if not new_rule["nodes"]:
raise MKUserError(None,
_("Please add at least one child node. Empty rules are useless."))
@@ -1380,11 +1400,25 @@ class ModeBIEditRule(ModeBI):
raise MKUserError(None, _("There is a cycle in your rules. This rule calls itself - "
"either directly or indirectly."))
log_pending(SYNC, None, "bi-edit-rule", _("Modified BI rule %s") % self._ruleid)
+
self.save_config()
return "bi_rules"
+ def _rename_existing_ruleid_after_confirm(self, existing_ruleid):
+ for packinfo in self._packs.values():
+ for rule_id, rule_info in packinfo['rules'].items():
+ new_nodes = []
+ for this_node in rule_info.get('nodes', []):
+ node_ty, node_info = this_node
+ if node_ty == 'call' and existing_ruleid == node_info[0]:
+ new_nodes.append( ('call', tuple( [self._ruleid] + list(node_info)[1:] )) )
+ else:
+ new_nodes.append( this_node )
+ rule_info['nodes'] = new_nodes
+
+
def page(self):
if self._new:
cloneid = html.var("clone")
@@ -1410,6 +1444,16 @@ class ModeBIEditRule(ModeBI):
def valuespec(self):
elements = [
+ ( "id",
+ TextAscii(
+ title = _("Unique Rule ID"),
+ help = _("The ID of the rule must be a unique text. It will be used as an internal key "
+ "when rules refer to each other. The rule IDs will not be visible in the status "
+ "GUI. They are just used within the configuration."),
+ allow_empty = False,
+ size = 24,
+ ),
+ ),
( "title",
TextUnicode(
title = _("Rule Title"),
@@ -1473,20 +1517,6 @@ class ModeBIEditRule(ModeBI):
),
]
-
- if self._new:
- elements = [
- ( "id",
- TextAscii(
- title = _("Unique Rule ID"),
- help = _("The ID of the rule must be a unique text. It will be used as an internal key "
- "when rules refer to each other. The rule IDs will not be visible in the status "
- "GUI. They are just used within the configuration."),
- allow_empty = False,
- size = 24,
- ),
- )] + elements
-
return Dictionary(
title = _("General Properties"),
optional_keys = False,