Ejemplo n.º 1
0
def graph_templates_autocompleter(value: str, params: Dict) -> Choices:
    """Return the matching list of dropdown choices
    Called by the webservice with the current input field value and the
    completions_params to get the list of choices"""
    if not params.get("context") and params.get("strict", "False") == "False":
        choices: Iterable[Tuple[str, str]] = ((
            graph_id,
            str(graph_details.get(
                "title",
                graph_id,
            )),
        ) for graph_id, graph_details in graph_info.items())

    else:
        columns = [
            "service_check_command",
            "service_perf_data",
            "service_metrics",
        ]

        choices = set(
            chain.from_iterable(
                _graph_choices_from_livestatus_row(row) for row in
                livestatus_query_bare("service", params["context"], columns)))

    return sorted((v for v in choices if value.lower() in v[1].lower()),
                  key=lambda a: a[1].lower())
Ejemplo n.º 2
0
def fixup_graph_info():
    # create back link from each graph to its id.
    for graph_id, graph in graph_info.items():
        graph["id"] = graph_id