Module: check_mk
Branch: master
Commit: 026db4decf67333703a7a7c2cede0b0c938d1a14
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=026db4decf6733…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 20 13:49:09 2015 +0200
Minor code cleanup in logwatch check
---
checks/logwatch | 40 +++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index eb505be..19a56cf 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -35,6 +35,17 @@ logwatch_groups = []
# Variables embedded in precompiled checks
check_config_variables += [ "logwatch_dir", "logwatch_max_filesize",
"logwatch_service_output" ]
+# .--General-------------------------------------------------------------.
+# | ____ _ |
+# | / ___| ___ _ __ ___ _ __ __ _| | |
+# | | | _ / _ \ '_ \ / _ \ '__/ _` | | |
+# | | |_| | __/ | | | __/ | | (_| | | |
+# | \____|\___|_| |_|\___|_| \__,_|_| |
+# | |
+# +----------------------------------------------------------------------+
+# | General functions, for normal and forwarding logwatch check |
+# '----------------------------------------------------------------------'
+
def logwatch_ec_forwarding_enabled(params, item):
if 'restrict_logfiles' not in params:
return True # matches all logs on this host
@@ -208,6 +219,18 @@ def logwatch_parse_line(line):
text = ""
return level, text
+#.
+# .--Logwatch------------------------------------------------------------.
+# | _ _ _ |
+# | | | ___ __ ___ ____ _| |_ ___| |__ |
+# | | |/ _ \ / _` \ \ /\ / / _` | __/ __| '_ \ |
+# | | | (_) | (_| |\ V V / (_| | || (__| | | | |
+# | |_|\___/ \__, | \_/\_/ \__,_|\__\___|_| |_| |
+# | |___/ |
+# +----------------------------------------------------------------------+
+# | Normal logwatch check |
+# '----------------------------------------------------------------------'
+
# In case of a precompiled check, params contains the precompiled
# logwatch_patterns for the logfile we deal with. If using check_mk
# without precompiled checks, the params must be None an will be
@@ -487,19 +510,18 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
else:
return (worst, "%s messages" % ', '.join(count_txt))
-# .----------------------------------------------------------------------.
-# | _____ ____ _____ ___ ______ ___ ____ ____ |
-# | | ____/ ___| | ___/ _ \| _ \ \ / / \ | _ \| _ \ |
-# | | _|| | | |_ | | | | |_) \ \ /\ / / _ \ | |_) | | | | |
-# | | |__| |___ | _|| |_| | _ < \ V V / ___ \| _ <| |_| | |
-# | |_____\____| |_| \___/|_| \_\ \_/\_/_/ \_\_| \_\____/ |
-# | |
+#.
+# .--Event Console Forwarding--------------------------------------------.
+# | _ _ _ |
+# | | | ___ __ ___ ____ _| |_ ___| |__ ___ ___ |
+# | | |/ _ \ / _` \ \ /\ / / _` | __/ __| '_ \ / _ \/ __| |
+# | | | (_) | (_| |\ V V / (_| | || (__| | | || __/ (__ |
+# | |_|\___/ \__, | \_/\_/ \__,_|\__\___|_| |_(_)___|\___| |
+# | |___/ |
# +----------------------------------------------------------------------+
# | Forwarding logwatch messages to event console |
# '----------------------------------------------------------------------'
-import socket, time
-
# OK -> priority 5 (notice)
# WARN -> priority 4 (warning)
# CRIT -> priority 2 (crit)