def _output_availability_timeline_csv(what: AVObjectType, av_entry: AVEntry, avoptions: AVOptions, timeline_nr: int) -> None: timeline_layout = availability.layout_timeline( what, av_entry["timeline"], av_entry["considered_duration"], avoptions, "standalone", ) object_cells = availability.get_object_cells(what, av_entry, avoptions["labelling"]) with table_element("av_timeline", "", output_format="csv", omit_headers=timeline_nr != 0) as table: for row in timeline_layout["table"]: table.row() table.text_cell("object_type", what) for cell_index, objectcell in enumerate(object_cells): table.text_cell("object_name_%d" % cell_index, objectcell[0]) table.text_cell("object_title", availability.object_title(what, av_entry)) table.text_cell("from", row["from"]) table.text_cell("from_text", row["from_text"]) table.text_cell("until", row["until"]) table.text_cell("until_text", row["until_text"]) table.text_cell("state", row["state"]) table.text_cell("state_name", row["state_name"]) table.text_cell("duration_text", row["duration_text"]) if "omit_timeline_plugin_output" not in avoptions["labelling"]: table.text_cell("log_output", row.get("log_output", "")) if "timeline_long_output" in avoptions["labelling"]: table.text_cell("long_log_output", row.get("long_log_output", ""))
def _render_availability_timeline(what, av_entry, avoptions, timeline_nr): # type: (AVObjectType, AVEntry, AVOptions, int) -> None html.open_h3() html.write("%s %s" % (_("Timeline of"), availability.object_title(what, av_entry))) html.close_h3() timeline_rows = av_entry["timeline"] if not timeline_rows: html.div(_("No information available"), class_="info") return timeline_layout = availability.layout_timeline( what, timeline_rows, av_entry["considered_duration"], avoptions, "standalone", ) render_timeline_bar(timeline_layout, "standalone", timeline_nr) # Table with detailed events with table_element("av_timeline", "", css="timelineevents", sortable=False, searchable=False) as table: for row_nr, row in enumerate(timeline_layout["table"]): table.row( id_="timetable_%d_entry_%d" % (timeline_nr, row_nr), onmouseover="cmk.availability.timetable_hover(%d, %d, 1);" % (timeline_nr, row_nr), onmouseout="cmk.availability.timetable_hover(%d, %d, 0);" % (timeline_nr, row_nr)) table.cell(_("Links"), css="buttons") if what == "bi": url = html.makeuri([("timewarp", str(int(row["from"])))]) if html.request.var( "timewarp" ) and html.request.get_integer_input_mandatory( "timewarp") == int(row["from"]): html.disabled_icon_button("timewarp_off") else: html.icon_button( url, _("Time warp - show BI aggregate during this time period" ), "timewarp") else: url = html.makeuri([("anno_site", av_entry["site"]), ("anno_host", av_entry["host"]), ("anno_service", av_entry["service"]), ("anno_from", str(row["from"])), ("anno_until", str(row["until"]))]) html.icon_button(url, _("Create an annotation for this period"), "annotation") table.cell(_("From"), row["from_text"], css="nobr narrow") table.cell(_("Until"), row["until_text"], css="nobr narrow") table.cell(_("Duration"), row["duration_text"], css="narrow number") table.cell(_("State"), row["state_name"], css=row["css"] + " state narrow") if "omit_timeline_plugin_output" not in avoptions["labelling"]: table.cell( _("Last Known Plugin Output"), format_plugin_output(row.get("log_output", ""), row)) if "timeline_long_output" in avoptions["labelling"]: table.cell( _("Last Known Long Output"), format_plugin_output(row.get("long_log_output", ""), row)) # Legend for timeline if "display_timeline_legend" in avoptions["labelling"]: render_timeline_legend(what)