Module: check_mk
Branch: master
Commit: abf003c73b1cfb3b72159e59b1234214be0bbe1c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=abf003c73b1cfb…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Feb 18 09:08:04 2016 +0100
#3077 FIX CSV export is now available for host/service availability and now includes
summary line
---
.werks/3077 | 10 ++++++++++
ChangeLog | 1 +
web/plugins/views/availability.py | 20 +++++++++++++++-----
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/.werks/3077 b/.werks/3077
new file mode 100644
index 0000000..dcc91df
--- /dev/null
+++ b/.werks/3077
@@ -0,0 +1,10 @@
+Title: CSV export is now available for host/service availability and now includes summary
line
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1455782640
+
+
diff --git a/ChangeLog b/ChangeLog
index 4bdaeb1..a66b5d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@
* 3059 FIX: Fixed highlighting of availability timeline time slices
* 3175 FIX: Fix timeranges of graphs that are embedded in a dashboard...
* 3076 FIX: fixed broken views in check_mk raw edition
+ * 3077 FIX: CSV export is now available for host/service availability and now
includes summary line
WATO:
* 3060 FIX: Folder properties: Fixed exception when a user has no alias set...
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index fe392be..038f71d 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -216,7 +216,7 @@ def render_availability_page(view, datasource, filterheaders,
display_options, o
html.context_button(_("Status View"), html.makeuri([("mode",
"status")]), "status")
if config.reporting_available():
html.context_button(_("Export as PDF"), html.makeuri([],
filename="report_instant.py"), "report")
- if av_mode == "availability":
+ if av_mode == "table":
html.context_button(_("Export as CSV"),
html.makeuri([("output_format", "csv_export")]),
"download_csv")
if av_mode == "timeline" or av_object:
@@ -802,17 +802,27 @@ def handle_edit_annotations():
# '----------------------------------------------------------------------'
def output_availability_csv(what, av_data, avoptions):
+ def cells_from_row(object_titles, cell_titles, row_object, row_cells):
+ for title, (name, url) in zip(object_titles, row_object):
+ table.cell(title, name)
+ for (title, help), (text, css) in zip(cell_titles, row_cells):
+ table.cell(title, text)
+
av_output_csv_mimetype(_("Check_MK-Availability"))
availability_tables = availability.compute_availability_groups(what, av_data,
avoptions)
table.begin("av_items", output_format = "csv")
for group_title, availability_table in availability_tables:
av_table = availability.layout_availability_table(what, group_title,
availability_table, avoptions)
+ pad = 0
for row in av_table["rows"]:
table.row()
- for title, (name, url) in zip(av_table["object_titles"],
row["object"]):
- table.cell(title, name)
- for (title, help), (text, css) in zip(av_table["cell_titles"],
row["cells"]):
- table.cell(title, text)
+ cells_from_row(av_table["object_titles"],
av_table["cell_titles"],
+ row["object"], row["cells"])
+ # presumably all rows have the same width
+ pad = len(row["object"]) - 1
+ table.row()
+ cells_from_row(av_table["object_titles"],
av_table["cell_titles"],
+ [(_("Summary"), "")] + [("",
"")] * pad, av_table["summary"])
table.end()
def av_output_csv_mimetype(title):