logwatch rules were ineffective
Message-ID: <54084bc2.9K9DvTWW336FJ0wm%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 1f51d62d603ef99f8c5d2de869c73239b90e54d4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f51d62d603ef9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 4 13:23:41 2014 +0200
logwatch: fixed bug from yesterday, logwatch rules were ineffective
---
checks/fileinfo | 2 +-
checks/logwatch | 18 +++++++-----------
web/htdocs/wato.py | 15 +++++++++++----
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/checks/fileinfo b/checks/fileinfo
index 0599650..3919f76 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -114,7 +114,7 @@ def fileinfo_groups_precompile(hostname, item, params):
for group_name, pattern in line:
if group_name == item:
if type(pattern) == str: # support old format
- pattern = ( pattern, '' )
+ pattern = (pattern, '')
patterns.append(pattern)
params['precompiled_patterns'] = patterns
return params
diff --git a/checks/logwatch b/checks/logwatch
index 549ea5a..2f4ebe9 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -83,11 +83,11 @@ def inventory_logwatch(info):
if groups:
continue
else:
- inventory.append((logfile, []))
+ inventory.append((logfile, None))
return inventory
-#logwatch_patterns = {
+# logwatch_patterns = {
# 'System': [
# ( 'W', 'sshd' ),
# ( ['host1', 'host2'], 'C', 'ssh' ), # only
applies to certain hosts
@@ -256,8 +256,8 @@ precompile_params['logwatch'] = logwatch_precompile
# | |
# '----------------------------------------------------------------------'
-def logwatch_group_precompile( hostname, item, _unused):
- return logwatch_precompile( hostname, item, None ), host_extra_conf( hostname,
logwatch_groups )
+def logwatch_group_precompile(hostname, item, _unused):
+ return logwatch_precompile(hostname, item, None), host_extra_conf(hostname,
logwatch_groups)
def logwatch_groups_of_logfile(filename, params=False):
import fnmatch
@@ -283,7 +283,7 @@ def inventory_logwatch_groups(info):
for group in groups:
if group not in added_groups:
added_groups.append(group)
- inventory.append((group, [] ))
+ inventory.append((group, None))
return inventory
def check_logwatch_groups(item, params, info):
@@ -359,9 +359,7 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
if os.path.exists(logfile) and os.path.getsize(logfile) > logwatch_max_filesize:
return (2, "unacknowledged messages have exceeded max size (%d Bytes)"
% logwatch_max_filesize)
- #
# Write out new log lines (no reclassify here. It is done later in general for all
logs)
- #
if len(loglines) > 0:
worst = -1
for line in loglines:
@@ -380,8 +378,8 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
# Get the patterns (either compile or reuse the precompiled ones)
# Check_MK creates an empty string if the precompile function has
- # not been exectued yet. The precomile function creates an empty
- # list when no rules/patterns are defined. In case of the logwatch.groups
+ # not been executed yet. The precompile function creates an empty
+ # list when no ruless/patterns are defined. In case of the logwatch.groups
# checks, params are a tuple with the normal logwatch parameters on the first
# and the grouping patterns on the second position
if params not in ('', None):
@@ -399,10 +397,8 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
level = newlevel
return level
- #
# Read current log messages, reclassify all messages and write out the
# whole file again if at least one line has been reclassified
- #
worst = 0
last_worst_line = ''
reclassified_lines = []
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 56681df..21f0a7b 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2705,9 +2705,9 @@ def mode_object_parameters(phase):
forms.end()
-PARAMETERS_UNKNOW = []
+PARAMETERS_UNKNOWN = []
PARAMETERS_OMIT = []
-def output_analysed_ruleset(all_rulesets, rulespec, hostname, service,
known_settings=PARAMETERS_UNKNOW):
+def output_analysed_ruleset(all_rulesets, rulespec, hostname, service,
known_settings=PARAMETERS_UNKNOWN):
def rule_url(rule):
rule_folder, rule_nr = rule
return make_link([
@@ -2741,11 +2741,18 @@ def output_analysed_ruleset(all_rulesets, rulespec, hostname,
service, known_set
# Show the resulting value or factory setting
html.write("<td class='settingvalue %s'>" % (len(rules) >
0 and "used" or "unused"))
- # In some cases we now the settings from a check_mk auomation
+ # In some cases we now the settings from a check_mk automation
if known_settings is PARAMETERS_OMIT:
return
- elif known_settings is not PARAMETERS_UNKNOW:
+ # Special handling for logwatch: The check parameter is always None. The actual
+ # patterns are configured in logwatch_rules. We do not have access to the actual
+ # patterns here but just to the useless "None". In order not to complicate
things
+ # we simply display nothing here.
+ elif varname == "logwatch_rules":
+ pass
+
+ elif known_settings is not PARAMETERS_UNKNOWN:
html.write(valuespec.value_to_text(known_settings))
else: