示例#1
0
def graph_spec_from_request(request):
    graph_data_range, graph_recipes = graph_recipes_for_api_request(request)

    try:
        graph_recipe = graph_recipes[0]
    except IndexError:
        raise MKUserError(None, _("The requested graph does not exist"))

    curves = artwork.compute_graph_artwork_curves(graph_recipe,
                                                  graph_data_range)

    api_curves = []
    (start_time,
     end_time), step = graph_data_range["time_range"], 60  # empty graph

    for c in curves:
        start_time, end_time, step = c["rrddata"].twindow
        api_curve = c.copy()
        api_curve["rrddata"] = c["rrddata"].values
        api_curves.append(api_curve)

    return {
        "start_time": start_time,
        "end_time": end_time,
        "step": step,
        "curves": api_curves,
    }
示例#2
0
def render_ajax_graph_hover(context, hover_time):
    graph_data_range = context["data_range"]
    graph_recipe = context["definition"]

    curves = artwork.compute_graph_artwork_curves(graph_recipe, graph_data_range)

    curve_values = artwork._compute_curve_values_at_timestamp(graph_recipe, curves, hover_time)

    return {
        "rendered_hover_time": cmk.utils.render.date_and_time(hover_time),
        "curve_values": curve_values,
    }