Module: check_mk
Branch: master
Commit: 52fc4fa3cd0f328ac317a000a65c57f9a6e1ccdc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=52fc4fa3cd0f32…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Tue May 8 12:53:23 2018 +0200
logwatch: compute pattern hash with hashlib
Change-Id: Ia1838c8a2693265594b9506abb07514a6f342fd2
---
checks/logwatch | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index a54eb4c..e32dfe8 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -504,6 +504,7 @@ def logwatch_username():
def check_logwatch_generic(item, params, loglines, found, groups=False):
+ import hashlib
logdir = logwatch_dir + "/" + host_name()
# Create directories, if neccessary
@@ -605,7 +606,7 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
except Exception, e:
raise MKGeneralException("User %s cannot open file for writing: %s" %
(logwatch_username(), e))
- pattern_hash = hash(repr(patterns))
+ pattern_hash = hashlib.sha256(repr(patterns)).hexdigest()
net_lines = 0
# parse cached log lines
if log_exists:
@@ -613,7 +614,7 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
# changed
initline = logwatch_file.readline().rstrip('\n')
if initline.startswith('[[[') and initline.endswith(']]]'):
- old_pattern_hash = int(initline[3:-3])
+ old_pattern_hash = initline[3:-3]
skip_reclassification = old_pattern_hash == pattern_hash
else:
logwatch_file.seek(0)
@@ -675,7 +676,7 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
if not skip_reclassification and collect_block.output_lines:
logwatch_file.seek(0)
logwatch_file.truncate()
- logwatch_file.write("[[[%d]]]\n" % pattern_hash)
+ logwatch_file.write("[[[%s]]]\n" % pattern_hash)
if collect_block.output_lines:
logwatch_file.writelines(collect_block.output_lines)