Module: check_mk
Branch: master
Commit: 4f2bfb4082cf962f2301385084cf41a2df9eded5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f2bfb4082cf96…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Nov 24 15:56:17 2017 +0100
5521 FIX logwatch: Fix exception in WATO's check parameter display
Previously, WATO's check parameter display would complain about invalid check parameters,
due to logwatch's parameter precompilation working well with the check itself, but
breaking the GUI's validation. This was a purely cosmetic issue.
Change-Id: I1743feca52e8848fa5bc30968a912c07988e1052
---
.werks/5521 | 13 +++++++++++++
checks/logwatch | 20 ++++++++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/.werks/5521 b/.werks/5521
new file mode 100644
index 0000000..0819951
--- /dev/null
+++ b/.werks/5521
@@ -0,0 +1,13 @@
+Title: logwatch: Fix exception in WATO's check parameter display
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i2
+Date: 1511534791
+
+Previously, WATO's check parameter display would complain about invalid check parameters,
+due to logwatch's parameter precompilation working well with the check itself, but
+breaking the GUI's validation. This was a purely cosmetic issue.
diff --git a/checks/logwatch b/checks/logwatch
index 3ae71a4..e92d711 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -153,19 +153,24 @@ def logwatch_level_worst(worst, level):
# Extracts patterns that are relevant for the current host and item.
# Constructs simple list of pairs: [ ('W', 'crash.exe'), ('C', 'sshd.*test') ]
-def logwatch_precompile(hostname, item, params):
- params = {"reclassify_patterns": [], "reclassify_states": {}}
+def logwatch_precompile(hostname, item, _unused):
+ # Initialize the patterns list with the logwatch_rules
+ params = {"reclassify_patterns": []}
# This is the new (-> WATO controlled) variable
rules = service_extra_conf(hostname, item, logwatch_rules)
for rule in rules:
if isinstance(rule, dict):
- params["reclassify_patterns"].extend(x[:2] for x in rule.get("reclassify_patterns"))
+ params["reclassify_patterns"].extend(x for x in rule.get("reclassify_patterns"))
if "reclassify_states" in rule:
+ # NOTE: This key cannot be set unless it contains a valid entry.
+ # The check does not care either way, but the GUI's validation fails
+ # if it is passed to it with an empty dict.
+ params.setdefault("reclassify_states", {})
params["reclassify_states"] = rule["reclassify_states"]
else:
- params["reclassify_patterns"].extend(x[:2] for x in rule)
+ params["reclassify_patterns"].extend(x for x in rule)
# Now load the old logwatch_patterns var
patterns = logwatch_patterns.get(item)
@@ -187,7 +192,10 @@ def logwatch_precompile(hostname, item, params):
in_extraconf_hostlist(hostlist, hostname)):
continue
- params["reclassify_patterns"].append((level, pattern))
+ # All entries need to be 3-Tuples to be compatible with the wato rule.
+ # The third entry is a comment not used in the check anyway, so we just
+ # fill it with None here.
+ params["reclassify_patterns"].append((level, pattern, None))
return params
@@ -203,7 +211,7 @@ def logwatch_reclassify(counts, patterns, text, old_level):
# Reclassify state if a given regex pattern matches
# A match overrules the previous state->state reclassification
- for level, pattern in patterns.get("reclassify_patterns", []):
+ for level, pattern, _ in patterns.get("reclassify_patterns", []):
reg = regex(pattern)
if reg.search(text):
# If the level is not fixed like 'C' or 'W' but a pair like (10, 20),
Module: check_mk
Branch: master
Commit: 2d3b9703970d787d40e01f88a169a471abebf974
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2d3b9703970d78…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 24 15:50:19 2017 +0100
5540 FIX "Graph time range" display option had no effect on Check_MK graphs
The graph time range configured in the view is the "default" time range and
the display option is meant to override this view default.
Change-Id: I7d11f8e20049bc739c03b71b6a73fab9db16d379
---
.werks/5540 | 12 ++++++++++++
web/plugins/views/painters.py | 13 ++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/.werks/5540 b/.werks/5540
new file mode 100644
index 0000000..3c41046
--- /dev/null
+++ b/.werks/5540
@@ -0,0 +1,12 @@
+Title: "Graph time range" display option had no effect on Check_MK graphs
+Level: 1
+Component: metrics
+Class: fix
+Compatible: compat
+Edition: cee
+State: unknown
+Version: 1.5.0i2
+Date: 1511534729
+
+The graph time range configured in the view is the "default" time range and
+the display option is meant to override this view default.
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index b0c7fe8..be8c166 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -1013,20 +1013,31 @@ def paint_time_graph_cmk(row, cell, show_timeranges=False):
"host_name" : row["host_name"],
"service_description" : row.get("service_description", "_HOST_"),
})
- graph_data_range = { "time_range" : get_graph_timerange_from_painter_options() }
# Load the graph render options from
# a) the painter parameters configured in the view
# b) the painter options set per user and view
graph_render_options = cell.painter_parameters().copy()
+ graph_data_range = {}
graph_render_options["show_time_range_previews"] = show_timeranges
options = painter_options.get_without_default("graph_render_options")
if options != None:
graph_render_options.update(options)
+ # Do not load this setting form the painter options
del graph_render_options["set_default_time_range"]
+ if "set_default_time_range" in graph_render_options:
+ duration = graph_render_options["set_default_time_range"]
+ now = time.time()
+ graph_data_range["time_range"] = now - duration, now
+
+ # Load timerange from painter option (overrides the defaults, if set by the user)
+ painter_option_pnp_timerange = painter_options.get_without_default("pnp_timerange")
+ if painter_option_pnp_timerange is not None:
+ graph_data_range["time_range"] = get_graph_timerange_from_painter_options()
+
if html.is_mobile():
graph_render_options.update({
"interaction" : False,
Module: check_mk
Branch: master
Commit: b8538679c7dafc9ae067d0815c49cbf04aacdf8b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b8538679c7dafc…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Nov 24 14:43:00 2017 +0100
5413 FIX Windows agent: nocontext tag did not work for multibyte encoded logfiles
If a Windows logfile was encoded with a multibyte character encoding
the nocontext flag had no effect, always outputting the full context.
The nocontext tag now works correctly, in a way similar to single-byte
encoded logfiles.
Change-Id: Idcca870974ac26da4b8961ad35ba446d90b28897
---
.werks/5413 | 16 ++++++++++++++++
agents/windows/build_version | 2 +-
agents/windows/sections/SectionLogwatch.cc | 3 ++-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/.werks/5413 b/.werks/5413
new file mode 100644
index 0000000..ab135d7
--- /dev/null
+++ b/.werks/5413
@@ -0,0 +1,16 @@
+Title: Windows agent: nocontext tag did not work for multibyte encoded logfiles
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1511530638
+Class: fix
+
+If a Windows logfile was encoded with a multibyte character encoding
+the nocontext flag had no effect, always outputting the full context.
+
+The nocontext tag now works correctly, in a way similar to single-byte
+encoded logfiles.
+
+
diff --git a/agents/windows/build_version b/agents/windows/build_version
index eab009b..e8fdf6b 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3006
+3008
diff --git a/agents/windows/sections/SectionLogwatch.cc b/agents/windows/sections/SectionLogwatch.cc
index f179114..b436cf8 100644
--- a/agents/windows/sections/SectionLogwatch.cc
+++ b/agents/windows/sections/SectionLogwatch.cc
@@ -312,7 +312,8 @@ SectionLogwatch::processTextfileUnicode(FILE *file, logwatch_textfile *textfile,
}
// Output line
- if (write_output && !output_buffer.empty()) {
+ if (write_output && !output_buffer.empty() &&
+ !(textfile->nocontext && (state == 'I' || state == '.'))) {
out << state << " " << output_buffer << "\n";
}
Module: check_mk
Branch: master
Commit: 662af878e1381595e2727cd54c82283f691dde22
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=662af878e13815…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Nov 24 14:35:30 2017 +0100
5412 FIX Windows agent: fix logfile glob patterns without '*' at the end
Windows logfile patterns have required a wildcard '*' at the end in
order to work correctly. It was not possible to require an exact match
to the end of a line without wildcard '*' at the end. The reason was a
carriage-return (CR) character at the end of each read line that
prevented a match unless a '*' was present at the end of the pattern.
Now also patterns without a wildcard '*' at the end work correctly.
Change-Id: I576b6302e333bfc6eb2014bcc759caa0e17eeb0f
---
.werks/5412 | 16 ++++++++++++++++
agents/windows/build_version | 2 +-
agents/windows/sections/SectionLogwatch.cc | 23 +++++++++++++++++------
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/.werks/5412 b/.werks/5412
new file mode 100644
index 0000000..c072659
--- /dev/null
+++ b/.werks/5412
@@ -0,0 +1,16 @@
+Title: Windows agent: fix logfile glob patterns without '*' at the end
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cre
+Version: 1.5.0i2
+Date: 1511530237
+Class: fix
+
+Windows logfile patterns have required a wildcard '*' at the end in
+order to work correctly. It was not possible to require an exact match
+to the end of a line without wildcard '*' at the end. The reason was a
+carriage-return (CR) character at the end of each read line that
+prevented a match unless a '*' was present at the end of the pattern.
+
+Now also patterns without a wildcard '*' at the end work correctly.
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 533bca3..eab009b 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3004
+3006
diff --git a/agents/windows/sections/SectionLogwatch.cc b/agents/windows/sections/SectionLogwatch.cc
index 7e9867b..f179114 100644
--- a/agents/windows/sections/SectionLogwatch.cc
+++ b/agents/windows/sections/SectionLogwatch.cc
@@ -216,17 +216,19 @@ void SectionLogwatch::saveOffsets(const std::string &logwatch_statefile) {
}
}
+namespace {
+
// Process content of the given textfile
// Can be called in dry-run mode (write_output = false). This tries to detect
// CRIT or WARN patterns
// If write_output is set to true any data found is written to the out socket
-int fill_unicode_bytebuffer(FILE *file, char *buffer, int offset) {
+inline int fill_unicode_bytebuffer(FILE *file, char *buffer, int offset) {
int bytes_to_read = UNICODE_BUFFER_SIZE - offset;
int read_bytes = fread(buffer + offset, 1, bytes_to_read, file);
return read_bytes + offset;
}
-int find_crnl_end(char *buffer) {
+inline int find_crnl_end(char *buffer) {
for (size_t index = 0; index < UNICODE_BUFFER_SIZE; index += 2) {
if (buffer[index] == 0x0d && index < UNICODE_BUFFER_SIZE - 2 &&
buffer[index + 2] == 0x0a)
@@ -235,6 +237,14 @@ int find_crnl_end(char *buffer) {
return -1;
}
+inline void rtrim(std::string &s) {
+ s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
+ return !std::isspace(ch);
+ }).base(), s.end());
+}
+
+} //namespace
+
SectionLogwatch::ProcessTextfileResponse
SectionLogwatch::processTextfileUnicode(FILE *file, logwatch_textfile *textfile,
std::ostream &out, bool write_output) {
@@ -276,6 +286,7 @@ SectionLogwatch::processTextfileUnicode(FILE *file, logwatch_textfile *textfile,
// Argh! The wstring needs to be cut at CRLF as it may go on beyond that
unicode_wstr.resize(buffer_size);
std::string output_buffer = to_utf8(unicode_wstr);
+ rtrim(output_buffer);
Debug(_logger)
<< "SectionLogwatch::processTextfileUnicode, output_buffer: "
<< output_buffer;
@@ -344,12 +355,12 @@ SectionLogwatch::processTextfileDefault(FILE *file, logwatch_textfile *textfile,
while (!feof(file)) {
if (!fgets(line, sizeof(line), file)) break;
-
- if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = 0;
+ std::string lineString(line);
+ rtrim(lineString);
char state = '.';
for (condition_pattern *pattern : *textfile->patterns) {
- if (globmatch(pattern->glob_pattern, line)) {
+ if (globmatch(pattern->glob_pattern, lineString.c_str())) {
if (!write_output &&
(pattern->state == 'C' || pattern->state == 'W' ||
pattern->state == 'O')) {
@@ -364,7 +375,7 @@ SectionLogwatch::processTextfileDefault(FILE *file, logwatch_textfile *textfile,
if (write_output && strlen(line) > 0 &&
!(textfile->nocontext && (state == 'I' || state == '.')))
- out << state << " " << line << "\n";
+ out << state << " " << lineString << "\n";
}
response.found_match = false;