Example #1
0
def _metrics(summary, task_id, json_):
    """
    Get metrics from the specified task.

    :param summary: summarise output if true, output all if false
    :type summary: bool
    :param task_id: mesos task id
    :type task_id: str
    :param json: print raw JSON
    :type json: bool
    :return: Process status
    :rtype: int
    """

    master = mesos.get_master()
    task = master.task(task_id)
    if 'slave_id' not in task:
        raise DCOSException(
            'Error finding agent associated with task: {}'.format(task_id))

    slave_id = task['slave_id']
    container_id = master.get_container_id(task_id)

    endpoint = '/system/v1/agent/{}/metrics/v0/containers/{}'.format(
        slave_id, container_id)
    dcos_url = config.get_config_val('core.dcos_url').rstrip('/')
    if not dcos_url:
        raise config.missing_config_exception(['core.dcos_url'])

    url = dcos_url + endpoint
    app_url = url + '/app'
    return metrics.print_task_metrics(url, app_url, summary, json_)
Example #2
0
def _metrics(summary, task_id, json_):
    """
    Get metrics from the specified task.

    :param summary: summarise output if true, output all if false
    :type summary: bool
    :param task_id: mesos task id
    :type task_id: str
    :param json: print raw JSON
    :type json: bool
    :return: Process status
    :rtype: int
    """

    master = mesos.get_master()
    task = master.task(task_id)
    if 'slave_id' not in task:
        raise DCOSException(
            'Error finding agent associated with task: {}'.format(task_id))

    slave_id = task['slave_id']
    container_id = master.get_container_id(task_id)

    endpoint = '/system/v1/agent/{}/metrics/v0/containers/{}'.format(
        slave_id, container_id
    )
    dcos_url = config.get_config_val('core.dcos_url').rstrip('/')
    if not dcos_url:
        raise config.missing_config_exception(['core.dcos_url'])

    url = dcos_url + endpoint
    app_url = url + '/app'
    return metrics.print_task_metrics(url, app_url, summary, json_)