def render_availability_page(view, datasource, filterheaders, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Deletion must take place before computation, since it affects the outcome html.plug() handle_delete_annotations() confirmation_html_code = html.drain() html.unplug() # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata, has_reached_logrow_limit = \ availability.get_availability_rawdata(what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if display_options.enabled(display_options.H): html.body_start(title, stylesheets=["pages", "views", "status"], force=True) if display_options.enabled(display_options.T): html.top_heading(title) html.write(confirmation_html_code) # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if display_options.enabled(display_options.B): html.begin_context_buttons() togglebutton("avoptions", html.has_user_errors(), "painteroptions", _("Configure details of the report")) html.context_button(_("Status View"), html.makeuri([("mode", "status")]), "status") if config.reporting_available() and config.user.may( "general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") 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: html.context_button( _("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): # If we abolish the limit we have to fetch the data again # with changed logrow_limit = 0, which means no limit if has_reached_logrow_limit: text = _( "Your query matched more than %d log entries. " "<b>Note:</b> The number of shown rows does not necessarily reflect the " "matched entries and the result might be incomplete. " ) % avoptions["logrow_limit"] text += '<a href="%s">%s</a>' % \ (html.makeuri([("_unset_logrow_limit", "1"), ("avo_logrow_limit", 0)]), _('Repeat query without limit.')) html.show_warning(text) do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if display_options.enabled(display_options.Z): html.bottom_footer() if display_options.enabled(display_options.H): html.body_end()
def render_bi_availability(title, aggr_rows): av_mode = html.var("av_mode", "availability") avoptions = get_availability_options_from_url("bi") time_range, range_title = avoptions["range"] if av_mode == "timeline": title = _("Timeline of ") + title else: title = _("Availability of ") + title if html.output_format != "csv_export": html.body_start(title, stylesheets=["pages", "views", "status", "bi"], javascripts=['bi']) html.top_heading(title) html.begin_context_buttons() togglebutton("avoptions", False, "painteroptions", _("Configure details of the report")) html.context_button(_("Status View"), html.makeuri([("mode", "status")]), "status") if config.reporting_available() and config.user.may( "general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") if av_mode == "availability": html.context_button( _("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline": html.context_button(_("Availability"), html.makeuri([("av_mode", "availability")]), "availability") elif len(aggr_rows) == 1: aggr_name = aggr_rows[0]["aggr_name"] aggr_group = aggr_rows[0]["aggr_group"] timeline_url = html.makeuri([("av_mode", "timeline"), ("av_aggr_name", aggr_name), ("av_aggr_group", aggr_group)]) html.context_button(_("Timeline"), timeline_url, "timeline") html.end_context_buttons() avoptions = render_availability_options("bi") timewarpcode = "" if not html.has_user_errors(): countdown_logrow_limit = avoptions["logrow_limit"] has_reached_logrow_limit = False spans = [] for aggr_row in aggr_rows: tree = aggr_row["aggr_tree"] reqhosts = tree["reqhosts"] try: timewarp = int(html.var("timewarp")) except: timewarp = None (these_spans, timewarp_tree_state), countdown_logrow_limit = \ availability.get_bi_spans(tree, aggr_row["aggr_group"], avoptions, countdown_logrow_limit, timewarp) # We take only complete aggregations i.d. if we have # undershot the log row limit then we ignore the rest if avoptions["logrow_limit"] and countdown_logrow_limit < 0: has_reached_logrow_limit = True break spans += these_spans if timewarp and timewarp_tree_state: state, assumed_state, node, subtrees = timewarp_tree_state eff_state = state if assumed_state != None: eff_state = assumed_state row = { "aggr_tree": tree, "aggr_treestate": timewarp_tree_state, "aggr_state": state, # state disregarding assumptions "aggr_assumed_state": assumed_state, # is None, if there are no assumptions "aggr_effective_state": eff_state, # is assumed_state, if there are assumptions, else real state "aggr_name": node["title"], "aggr_output": eff_state["output"], "aggr_hosts": node["reqhosts"], "aggr_function": node["func"], "aggr_group": html.var("aggr_group"), } tdclass, htmlcode = bi.render_tree_foldable( row, boxes=False, omit_root=False, expansion_level=bi.load_ex_level(), only_problems=False, lazy=False) html.plug() # TODO: SOMETHING IS WRONG IN HERE (used to be the same situation in original code!) html.open_h3() # render icons for back and forth if int(these_spans[0]["from"]) == timewarp: html.disabled_icon_button("back_off") have_forth = False previous_span = None for span in these_spans: if int(span["from"]) == timewarp and previous_span != None: html.icon_button( html.makeuri([("timewarp", str(int(previous_span["from"])))]), _("Jump one phase back"), "back") elif previous_span and int( previous_span["from"] ) == timewarp and span != these_spans[-1]: html.icon_button( html.makeuri([("timewarp", str(int(span["from"])))]), _("Jump one phase forth"), "forth") have_forth = True previous_span = span if not have_forth: html.disabled_icon_button("forth_off") html.write(" ") html.icon_button(html.makeuri([("timewarp", "")]), _("Close Timewarp"), "closetimewarp") timewarpcode = html.drain() html.unplug() timewarpcode += '%s %s</h3>' % (_("Timewarp to "), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(timewarp))) + \ '<table class="data table timewarp"><tr class="data odd0"><td class="%s">' % tdclass + \ htmlcode + \ '</td></tr></table>' # Note: 'spans_by_object' returns two arguments which are used by # all availability views but not by BI. There we have to take # only complete aggregations av_rawdata = availability.spans_by_object(spans, None)[0] av_data = availability.compute_availability("bi", av_rawdata, avoptions) # If we abolish the limit we have to fetch the data again # with changed logrow_limit = 0, which means no limit if has_reached_logrow_limit: text = _( "Your query matched more than %d log entries. " "<b>Note:</b> The number of shown rows does not necessarily reflect the " "matched entries and the result might be incomplete. " ) % avoptions["logrow_limit"] text += '<a href="%s">%s</a>' % \ (html.makeuri([("_unset_logrow_limit", "1")]), _('Repeat query without limit.')) html.show_warning(text) if html.output_format == "csv_export": output_availability_csv("bi", av_data, avoptions) return html.write(timewarpcode) do_render_availability("bi", av_rawdata, av_data, av_mode, None, avoptions) # , timewarpcode) html.bottom_footer() html.body_end()
def render_bi_availability(title, aggr_rows): av_mode = html.var("av_mode", "availability") avoptions = get_availability_options_from_url("bi") time_range, range_title = avoptions["range"] if av_mode == "timeline": title = _("Timeline of ") + title else: title = _("Availability of ") + title if html.output_format != "csv_export": html.body_start(title, stylesheets=["pages", "views", "status", "bi"], javascripts=['bi']) html.top_heading(title) html.begin_context_buttons() togglebutton("avoptions", False, "painteroptions", _("Configure details of the report")) html.context_button(_("Status View"), html.makeuri([("mode", "status")]), "status") if config.reporting_available() and config.may("general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") if av_mode == "availability": html.context_button( _("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline": html.context_button(_("Availability"), html.makeuri([("av_mode", "availability")]), "availability") elif len(aggr_rows) == 1: aggr_name = aggr_rows[0]["aggr_name"] aggr_group = aggr_rows[0]["aggr_group"] timeline_url = html.makeuri([("av_mode", "timeline"), ("av_aggr_name", aggr_name), ("av_aggr_group", aggr_group)]) html.context_button(_("Timeline"), timeline_url, "timeline") html.end_context_buttons() avoptions = render_availability_options("bi") timewarpcode = "" if not html.has_user_errors(): spans = [] for aggr_row in aggr_rows: tree = aggr_row["aggr_tree"] reqhosts = tree["reqhosts"] try: timewarp = int(html.var("timewarp")) except: timewarp = None these_spans, timewarp_tree_state = availability.get_bi_spans( tree, aggr_row["aggr_group"], avoptions, timewarp) spans += these_spans if timewarp and timewarp_tree_state: state, assumed_state, node, subtrees = timewarp_tree_state eff_state = state if assumed_state != None: eff_state = assumed_state row = { "aggr_tree": tree, "aggr_treestate": timewarp_tree_state, "aggr_state": state, # state disregarding assumptions "aggr_assumed_state": assumed_state, # is None, if there are no assumptions "aggr_effective_state": eff_state, # is assumed_state, if there are assumptions, else real state "aggr_name": node["title"], "aggr_output": eff_state["output"], "aggr_hosts": node["reqhosts"], "aggr_function": node["func"], "aggr_group": html.var("aggr_group"), } tdclass, htmlcode = bi.render_tree_foldable( row, boxes=False, omit_root=False, expansion_level=bi.load_ex_level(), only_problems=False, lazy=False) html.plug() html.write('<h3>') # render icons for back and forth if int(these_spans[0]["from"]) == timewarp: html.disabled_icon_button("back_off") have_forth = False previous_span = None for span in these_spans: if int(span["from"]) == timewarp and previous_span != None: html.icon_button( html.makeuri([("timewarp", str(int(previous_span["from"])))]), _("Jump one phase back"), "back") elif previous_span and int( previous_span["from"] ) == timewarp and span != these_spans[-1]: html.icon_button( html.makeuri([("timewarp", str(int(span["from"])))]), _("Jump one phase forth"), "forth") have_forth = True previous_span = span if not have_forth: html.disabled_icon_button("forth_off") html.write(" ") html.icon_button(html.makeuri([("timewarp", "")]), _("Close Timewarp"), "closetimewarp") timewarpcode = html.drain() html.unplug() timewarpcode += '%s %s</h3>' % (_("Timewarp to "), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(timewarp))) + \ '<table class="data table timewarp"><tr class="data odd0"><td class="%s">' % tdclass + \ htmlcode + \ '</td></tr></table>' av_rawdata = availability.spans_by_object(spans) av_data = availability.compute_availability("bi", av_rawdata, avoptions) if html.output_format == "csv_export": output_availability_csv("bi", av_data, avoptions) return html.write(timewarpcode) do_render_availability("bi", av_rawdata, av_data, av_mode, None, avoptions) # , timewarpcode) html.bottom_footer() html.body_end()
def render_availability_page(view, datasource, filterheaders, display_options, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata = availability.get_availability_rawdata( what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if 'H' in display_options: html.body_start(title, stylesheets=["pages", "views", "status"], force=True) if 'T' in display_options: html.top_heading(title) handle_delete_annotations() # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if 'B' in display_options: html.begin_context_buttons() togglebutton("avoptions", html.has_user_errors(), "painteroptions", _("Configure details of the report")) html.context_button(_("Status View"), html.makeuri([("mode", "status")]), "status") if config.reporting_available() and config.may("general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") 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: html.context_button( _("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if 'Z' in display_options: html.bottom_footer() if 'H' in display_options: html.body_end()
def render_bi_availability(title, aggr_rows): av_mode = html.var("av_mode", "availability") avoptions = get_availability_options_from_url("bi") time_range, range_title = avoptions["range"] if av_mode == "timeline": title = _("Timeline of ") + title else: title = _("Availability of ") + title if html.output_format != "csv_export": html.body_start(title, stylesheets=["pages","views","status", "bi"], javascripts=['bi']) html.top_heading(title) html.begin_context_buttons() togglebutton("avoptions", False, "painteroptions", _("Configure details of the report")) 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": html.context_button(_("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline": html.context_button(_("Availability"), html.makeuri([("av_mode", "availability")]), "availability") elif len(aggr_rows) == 1: aggr_name = aggr_rows[0]["aggr_name"] aggr_group = aggr_rows[0]["aggr_group"] timeline_url = html.makeuri([("av_mode", "timeline"), ("av_aggr_name", aggr_name), ("av_aggr_group", aggr_group)]) html.context_button(_("Timeline"), timeline_url, "timeline") html.end_context_buttons() avoptions = render_availability_options("bi") timewarpcode = "" if not html.has_user_errors(): spans = [] for aggr_row in aggr_rows: tree = aggr_row["aggr_tree"] reqhosts = tree["reqhosts"] try: timewarp = int(html.var("timewarp")) except: timewarp = None these_spans, timewarp_tree_state = availability.get_bi_spans(tree, aggr_row["aggr_group"], avoptions, timewarp) spans += these_spans if timewarp and timewarp_tree_state: state, assumed_state, node, subtrees = timewarp_tree_state eff_state = state if assumed_state != None: eff_state = assumed_state row = { "aggr_tree" : tree, "aggr_treestate" : timewarp_tree_state, "aggr_state" : state, # state disregarding assumptions "aggr_assumed_state" : assumed_state, # is None, if there are no assumptions "aggr_effective_state" : eff_state, # is assumed_state, if there are assumptions, else real state "aggr_name" : node["title"], "aggr_output" : eff_state["output"], "aggr_hosts" : node["reqhosts"], "aggr_function" : node["func"], "aggr_group" : html.var("aggr_group"), } tdclass, htmlcode = bi.render_tree_foldable(row, boxes=False, omit_root=False, expansion_level=bi.load_ex_level(), only_problems=False, lazy=False) html.plug() html.write('<h3>') # render icons for back and forth if int(these_spans[0]["from"]) == timewarp: html.disabled_icon_button("back_off") have_forth = False previous_span = None for span in these_spans: if int(span["from"]) == timewarp and previous_span != None: html.icon_button(html.makeuri([("timewarp", str(int(previous_span["from"])))]), _("Jump one phase back"), "back") elif previous_span and int(previous_span["from"]) == timewarp and span != these_spans[-1]: html.icon_button(html.makeuri([("timewarp", str(int(span["from"])))]), _("Jump one phase forth"), "forth") have_forth = True previous_span = span if not have_forth: html.disabled_icon_button("forth_off") html.write(" ") html.icon_button(html.makeuri([("timewarp", "")]), _("Close Timewarp"), "closetimewarp") timewarpcode = html.drain() html.unplug() timewarpcode += '%s %s</h3>' % (_("Timewarp to "), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(timewarp))) + \ '<table class="data table timewarp"><tr class="data odd0"><td class="%s">' % tdclass + \ htmlcode + \ '</td></tr></table>' av_rawdata = availability.spans_by_object(spans) av_data = availability.compute_availability("bi", av_rawdata, avoptions) if html.output_format == "csv_export": output_availability_csv("bi", av_data, avoptions) return html.write(timewarpcode) do_render_availability("bi", av_rawdata, av_data, av_mode, None, avoptions)# , timewarpcode) html.bottom_footer() html.body_end()
def render_availability_page(view, datasource, filterheaders, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Deletion must take place before computation, since it affects the outcome html.plug() handle_delete_annotations() confirmation_html_code = html.drain() html.unplug() # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata = availability.get_availability_rawdata(what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if DisplayOptions.enabled(DisplayOptions.H): html.body_start(title, stylesheets=["pages","views","status"], force=True) if DisplayOptions.enabled(DisplayOptions.T): html.top_heading(title) html.write(confirmation_html_code) # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if DisplayOptions.enabled(DisplayOptions.B): html.begin_context_buttons() togglebutton("avoptions", html.has_user_errors(), "painteroptions", _("Configure details of the report")) 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 == "table": html.context_button(_("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline" or av_object: html.context_button(_("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if DisplayOptions.enabled(DisplayOptions.Z): html.bottom_footer() if DisplayOptions.enabled(DisplayOptions.H): html.body_end()
def render_bi_availability(title, aggr_rows): av_mode = html.var("av_mode", "availability") avoptions = get_availability_options_from_url("bi") time_range, range_title = avoptions["range"] if av_mode == "timeline": title = _("Timeline of ") + title else: title = _("Availability of ") + title if html.output_format != "csv_export": html.body_start(title, stylesheets=["pages", "views", "status", "bi"], javascripts=["bi"]) html.top_heading(title) html.begin_context_buttons() togglebutton("avoptions", False, "painteroptions", _("Configure details of the report")) 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": html.context_button(_("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline": html.context_button(_("Availability"), html.makeuri([("av_mode", "availability")]), "availability") elif len(aggr_rows) == 1: aggr_name = aggr_rows[0]["aggr_name"] aggr_group = aggr_rows[0]["aggr_group"] timeline_url = html.makeuri( [("av_mode", "timeline"), ("av_aggr_name", aggr_name), ("av_aggr_group", aggr_group)] ) html.context_button(_("Timeline"), timeline_url, "timeline") html.end_context_buttons() avoptions = render_availability_options("bi") timewarpcode = "" if not html.has_user_errors(): countdown_logrow_limit = avoptions["logrow_limit"] has_reached_logrow_limit = False spans = [] for aggr_row in aggr_rows: tree = aggr_row["aggr_tree"] reqhosts = tree["reqhosts"] try: timewarp = int(html.var("timewarp")) except: timewarp = None (these_spans, timewarp_tree_state), countdown_logrow_limit = availability.get_bi_spans( tree, aggr_row["aggr_group"], avoptions, countdown_logrow_limit, timewarp ) # We take only complete aggregations i.d. if we have # undershot the log row limit then we ignore the rest if avoptions["logrow_limit"] and countdown_logrow_limit < 0: has_reached_logrow_limit = True break spans += these_spans if timewarp and timewarp_tree_state: state, assumed_state, node, subtrees = timewarp_tree_state eff_state = state if assumed_state != None: eff_state = assumed_state row = { "aggr_tree": tree, "aggr_treestate": timewarp_tree_state, "aggr_state": state, # state disregarding assumptions "aggr_assumed_state": assumed_state, # is None, if there are no assumptions "aggr_effective_state": eff_state, # is assumed_state, if there are assumptions, else real state "aggr_name": node["title"], "aggr_output": eff_state["output"], "aggr_hosts": node["reqhosts"], "aggr_function": node["func"], "aggr_group": html.var("aggr_group"), } tdclass, htmlcode = bi.render_tree_foldable( row, boxes=False, omit_root=False, expansion_level=bi.load_ex_level(), only_problems=False, lazy=False, ) html.plug() html.write("<h3>") # render icons for back and forth if int(these_spans[0]["from"]) == timewarp: html.disabled_icon_button("back_off") have_forth = False previous_span = None for span in these_spans: if int(span["from"]) == timewarp and previous_span != None: html.icon_button( html.makeuri([("timewarp", str(int(previous_span["from"])))]), _("Jump one phase back"), "back", ) elif previous_span and int(previous_span["from"]) == timewarp and span != these_spans[-1]: html.icon_button( html.makeuri([("timewarp", str(int(span["from"])))]), _("Jump one phase forth"), "forth" ) have_forth = True previous_span = span if not have_forth: html.disabled_icon_button("forth_off") html.write(" ") html.icon_button(html.makeuri([("timewarp", "")]), _("Close Timewarp"), "closetimewarp") timewarpcode = html.drain() html.unplug() timewarpcode += ( "%s %s</h3>" % (_("Timewarp to "), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(timewarp))) + '<table class="data table timewarp"><tr class="data odd0"><td class="%s">' % tdclass + htmlcode + "</td></tr></table>" ) # Note: 'spans_by_object' returns two arguments which are used by # all availability views but not by BI. There we have to take # only complete aggregations av_rawdata = availability.spans_by_object(spans, None)[0] av_data = availability.compute_availability("bi", av_rawdata, avoptions) # If we abolish the limit we have to fetch the data again # with changed logrow_limit = 0, which means no limit if has_reached_logrow_limit: text = ( _( "Your query matched more than %d log entries. " "<b>Note:</b> The number of shown rows does not necessarily reflect the " "matched entries and the result might be incomplete. " ) % avoptions["logrow_limit"] ) text += '<a href="%s">%s</a>' % ( html.makeuri([("_unset_logrow_limit", "1")]), _("Repeat query without limit."), ) html.show_warning(text) if html.output_format == "csv_export": output_availability_csv("bi", av_data, avoptions) return html.write(timewarpcode) do_render_availability("bi", av_rawdata, av_data, av_mode, None, avoptions) # , timewarpcode) html.bottom_footer() html.body_end()