Beispiel #1
0
def print_task_metrics(url, app_url, summary, json_):
    """Retrieve and pretty-print fields from the `dcos-metrics`' `containers/id`
    endpoint and `containers/id/app` endpoint.

    :param url: `dcos-metrics` `containers/id` endpoint
    :type url: str
    :param app_url: `dcos-metrics` `containers/id/app` endpoint
    :type app_url: str
    :param json_: print json list if true
    :type json_: bool
    :param summary: print summary if true, or all fields if false
    :type summary: bool
    :return: Process status
    :rtype: int
    """

    container_datapoints = _fetch_metrics_datapoints(url)
    app_datapoints = _fetch_metrics_datapoints(app_url)
    datapoints = container_datapoints + app_datapoints
    if len(datapoints) == 0:
        raise EmptyMetricsException()

    if summary:
        if json_:
            return emitter.publish(_task_summary_json(datapoints))
        table = tables.metrics_summary_table(_task_summary_data(datapoints))
    else:
        if json_:
            return emitter.publish(datapoints)
        table = tables.metrics_details_table(_format_datapoints(datapoints),
                                             False)

    return emitter.publish(table)
Beispiel #2
0
def print_node_metrics(url, summary, json_):
    """Retrieve and pretty-print key fields from the `dcos-metrics`' `node`
    endpoint.

    :param url: `dcos-metrics` `node` endpoint
    :type url: str
    :param summary: print summary if true, or all fields if false
    :type summary: bool
    :param json_: print json list if true
    :type json_: bool
    :returns: Process status
    :rtype: int
    """

    datapoints = _fetch_metrics_datapoints(url)

    if summary:
        if json_:
            return emitter.publish(_node_summary_json(datapoints))
        table = tables.metrics_summary_table(_node_summary_data(datapoints))
    else:
        if json_:
            return emitter.publish(datapoints)
        table = tables.metrics_details_table(_format_datapoints(datapoints))

    return emitter.publish(table)
Beispiel #3
0
def print_task_metrics(url, app_url, summary, json_):
    """Retrieve and pretty-print fields from the `dcos-metrics`' `containers/id`
    endpoint and `containers/id/app` endpoint.

    :param url: `dcos-metrics` `containers/id` endpoint
    :type url: str
    :param app_url: `dcos-metrics` `containers/id/app` endpoint
    :type app_url: str
    :param json_: print json list if true
    :type json_: bool
    :param summary: print summary if true, or all fields if false
    :type summary: bool
    :return: Process status
    :rtype: int
    """

    datapoints = _fetch_metrics_datapoints(url) + _fetch_metrics_datapoints(
        app_url)

    if summary:
        if json_:
            return emitter.publish(_task_summary_json(datapoints))
        table = tables.metrics_summary_table(_task_summary_data(datapoints))
    else:
        if json_:
            return emitter.publish(datapoints)
        table = tables.metrics_details_table(_format_datapoints(datapoints),
                                             False)

    return emitter.publish(table)
Beispiel #4
0
def print_node_metrics(url, summary, json_):
    """Retrieve and pretty-print key fields from the `dcos-metrics`' `node`
    endpoint.

    :param url: `dcos-metrics` `node` endpoint
    :type url: str
    :param summary: print summary if true, or all fields if false
    :type summary: bool
    :param json_: print json list if true
    :type json_: bool
    :returns: Process status
    :rtype: int
    """

    datapoints = _fetch_metrics_datapoints(url)

    if summary:
        if json_:
            return emitter.publish(_node_summary_json(datapoints))
        table = tables.metrics_summary_table(_node_summary_data(datapoints))
    else:
        if json_:
            return emitter.publish(datapoints)
        table = tables.metrics_details_table(_format_datapoints(datapoints))

    return emitter.publish(table)
Beispiel #5
0
 def _task_details_fn(datapoints):
     return tables.metrics_details_table(datapoints, False)
Beispiel #6
0
 def _task_details_fn(datapoints):
     return tables.metrics_details_table(datapoints, False)