Module: check_mk
Branch: master
Commit: 63a6b955e28d7b19875b43a608ceaab475a6ae55
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=63a6b955e28d7b…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Dec 13 09:50:04 2018 +0100
Use a context manager for file I/O in werks handling. Fixed decoding.
Note that first stripping and then decoding is simply wrong, it must be done
the other way round. The wrong order just works by accident with UTF-8.
Change-Id: Ib95c752e51fb680c7386c87723208e8516bc512f
---
cmk/werks.py | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/cmk/werks.py b/cmk/werks.py
index 6757763..0be76a0 100644
--- a/cmk/werks.py
+++ b/cmk/werks.py
@@ -26,6 +26,7 @@
"""Code for processing Check_MK werks. This is needed by several components,
so it's best place is in the central library."""
+import codecs
import os
import json
@@ -110,12 +111,8 @@ def load():
def load_precompiled_werks_file(path):
- werks = {}
-
- for werk_id, werk in json.load(open(path)).items():
- werks[int(werk_id)] = werk
-
- return werks
+ with open(path) as fp:
+ return {int(werk_id): werk for werk_id, werk in json.load(fp).iteritems()}
def load_raw_files(werks_dir):
@@ -148,19 +145,20 @@ def _load_werk(path):
"body": [],
}
in_header = True
- for line in file(path):
- line = line.strip().decode("utf-8")
- if in_header and not line:
- in_header = False
- elif in_header:
- key, text = line.split(":", 1)
- try:
- value = int(text.strip())
- except ValueError:
- value = text.strip()
- werk[key.lower()] = value
- else:
- werk["body"].append(line)
+ with codecs.open(path, encoding="utf-8") as fp:
+ for line in fp:
+ line = line.strip()
+ if in_header and not line:
+ in_header = False
+ elif in_header:
+ key, text = line.split(":", 1)
+ try:
+ value = int(text.strip())
+ except ValueError:
+ value = text.strip()
+ werk[key.lower()] = value
+ else:
+ werk["body"].append(line)
werk.setdefault("compatible", "compat")
werk.setdefault("edition", "cre")
Module: check_mk
Branch: master
Commit: c8cf15481eda5918897dcee18df56a48878a25a3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c8cf15481eda59…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Dec 13 09:00:07 2018 +0100
Nuked one more table.begin()/end() pair.
table.end()'s return value has been unused since 2015 (77d6eeec4), so we can
simplify things a bit and use open_table() in one more place.
Change-Id: Iffa56c4787d600b46af348f0ee9e8b94a670c0aa
---
cmk/gui/plugins/views/availability.py | 100 +++++++++++++++++-----------------
cmk/gui/table.py | 7 +--
2 files changed, 50 insertions(+), 57 deletions(-)
diff --git a/cmk/gui/plugins/views/availability.py b/cmk/gui/plugins/views/availability.py
index 4da0c91..f727c77 100644
--- a/cmk/gui/plugins/views/availability.py
+++ b/cmk/gui/plugins/views/availability.py
@@ -456,57 +456,55 @@ def render_availability_table(group_title, availability_table, what, avoptions):
# TODO: If summary line is activated, then sorting should now move that line to the
# top. It should also stay at the bottom. This would require an extension to the
# table.py module.
- table.begin(
- "av_items",
- av_table["title"],
- css="availability",
- searchable=False,
- limit=None,
- omit_headers="omit_headers" in avoptions["labelling"])
-
- show_urls, show_timeline = False, False
- for row in av_table["rows"]:
- table.row()
-
- # Column with icons
- timeline_url = None
- if row["urls"]:
- show_urls = True
- table.cell("", css="buttons")
- for image, tooltip, url in row["urls"]:
- html.icon_button(url, tooltip, image)
- if image == "timeline":
- timeline_url = url
-
- # Column with host/service or aggregate name
- for title, (name, url) in zip(av_table["object_titles"], row["object"]):
- table.cell(title, html.render_a(name, url))
-
- if "timeline" in row:
- show_timeline = True
- table.cell(_("Timeline"), css="timeline")
- html.open_a(href=timeline_url)
- render_timeline_bar(row["timeline"], "inline")
- html.close_a()
-
- # Columns with the actual availability data
- for (title, help_txt), (text, css) in zip(av_table["cell_titles"], row["cells"]):
- table.cell(title, text, css=css, help_txt=help_txt)
-
- if "summary" in av_table:
- table.row(css="summary", fixed=True)
- if show_urls:
- table.cell("", "") # Empty cell in URLs column
- table.cell("", _("Summary"), css="heading")
- for _x in xrange(1, len(av_table["object_titles"])):
- table.cell("", "") # empty cells, of more object titles than one
- if show_timeline:
- table.cell("", "")
-
- for (title, help_txt), (text, css) in zip(av_table["cell_titles"], av_table["summary"]):
- table.cell(title, text, css="heading " + css, help_txt=help_txt)
-
- return table.end() # returns Table data if fetch == True
+ with table.open_table(
+ "av_items",
+ av_table["title"],
+ css="availability",
+ searchable=False,
+ limit=None,
+ omit_headers="omit_headers" in avoptions["labelling"]):
+
+ show_urls, show_timeline = False, False
+ for row in av_table["rows"]:
+ table.row()
+
+ # Column with icons
+ timeline_url = None
+ if row["urls"]:
+ show_urls = True
+ table.cell("", css="buttons")
+ for image, tooltip, url in row["urls"]:
+ html.icon_button(url, tooltip, image)
+ if image == "timeline":
+ timeline_url = url
+
+ # Column with host/service or aggregate name
+ for title, (name, url) in zip(av_table["object_titles"], row["object"]):
+ table.cell(title, html.render_a(name, url))
+
+ if "timeline" in row:
+ show_timeline = True
+ table.cell(_("Timeline"), css="timeline")
+ html.open_a(href=timeline_url)
+ render_timeline_bar(row["timeline"], "inline")
+ html.close_a()
+
+ # Columns with the actual availability data
+ for (title, help_txt), (text, css) in zip(av_table["cell_titles"], row["cells"]):
+ table.cell(title, text, css=css, help_txt=help_txt)
+
+ if "summary" in av_table:
+ table.row(css="summary", fixed=True)
+ if show_urls:
+ table.cell("", "") # Empty cell in URLs column
+ table.cell("", _("Summary"), css="heading")
+ for _x in xrange(1, len(av_table["object_titles"])):
+ table.cell("", "") # empty cells, of more object titles than one
+ if show_timeline:
+ table.cell("", "")
+
+ for (title, help_txt), (text, css) in zip(av_table["cell_titles"], av_table["summary"]):
+ table.cell(title, text, css="heading " + css, help_txt=help_txt)
def render_timeline_bar(timeline_layout, style):
diff --git a/cmk/gui/table.py b/cmk/gui/table.py
index 14bdcd5..97b09ce 100644
--- a/cmk/gui/table.py
+++ b/cmk/gui/table.py
@@ -75,7 +75,7 @@ def groupheader(title):
def end():
assert tables
table = tables.pop()
- return table.end()
+ table.end()
def update_headinfo(num_rows):
@@ -214,11 +214,6 @@ class Table(object):
self.finish_previous()
html.unplug()
- # Output-Format "fetch" simply means that all data is being
- # returned as Python-values to be rendered somewhere else.
- if self.options["output_format"] == "fetch":
- return self.headers, self.rows
-
if not self.rows and self.options["omit_if_empty"]:
return
Module: check_mk
Branch: master
Commit: 9eb937d1ede16159f35210a06e9cf8ab5930ee84
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9eb937d1ede161…
Author: Andreas Umbreit <au(a)mathias-kettner.de>
Date: Wed Dec 12 08:40:49 2018 +0100
6934 FIX cmk-update-agent: Remove unnecessary check for python interpreter
Since Check_MK 1.5, the Agent Updater gets deployed as a binary file to
linux systems by default.
Hence it is no longer necessary to check for an available python2 interpreter
on agent installation unless the Agent Updater gets deployed as a script.
This werk adapts the agent's preinstall scripts so that no unnecessary checks are induced anymore.
CMK-1429
Change-Id: I89ca0abb2ef1ded0409725df7caa8249864c1d32
---
.werks/6934 | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/.werks/6934 b/.werks/6934
new file mode 100644
index 0000000..9037e11
--- /dev/null
+++ b/.werks/6934
@@ -0,0 +1,16 @@
+Title: cmk-update-agent: Remove unnecessary check for python interpreter
+Level: 1
+Component: agents
+Compatible: compat
+Edition: cee
+Version: 1.6.0i1
+Date: 1544600004
+Class: fix
+
+Since Check_MK 1.5, the Agent Updater gets deployed as a binary file to
+linux systems by default.
+
+Hence it is no longer necessary to check for an available python2 interpreter
+on agent installation unless the Agent Updater gets deployed as a script.
+
+This werk adapts the agent's preinstall scripts so that no unnecessary checks are induced anymore.
Module: check_mk
Branch: master
Commit: 2dc7becbea1097ca61b7677be7cbfbb8c6a616b0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2dc7becbea1097…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Dec 6 11:39:14 2018 +0100
6945 mk_filestats: Plugin to monitor files (Count, Age, Size)
A new plugin is introduced with a functionality similar to fileinfo.
It reports count, size and age of sets of files specified using a
globbing pattern.
However, this plugin is designed with large filesets in mind.
It therefore provides different options to reduce the data reported to
the Check_MK server and/or to avoid unnecessary stat calls on the client.
For more information, please refer to the "--help" option of the plugin
and the example configration file in agents/cfg_examples.
CMK-1059
Change-Id: Icf99831444a5258029ef37233406d515d1cb7f61
---
.werks/6945 | 18 +
agents/cfg_examples/mk_filestats.cfg | 45 ++
agents/plugins/mk_filestats.py | 519 +++++++++++++++++++++
checkman/filestats | 32 ++
checkman/filestats.count_only | 31 ++
checkman/filestats.extremes_only | 32 ++
checks/filestats | 264 +++++++++++
cmk/gui/plugins/wato/check_parameters/filestats.py | 130 ++++++
.../checks/generictests/datasets/filestats_1.py | 72 +++
.../generictests/datasets/filestats_count_only.py | 31 ++
tests/unit/cmk/gui/test_watolib.py | 2 +
tests/unit/plugins/test_mk_filestats.py | 117 +++++
12 files changed, 1293 insertions(+)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=2dc7becbea…