Exemple #1
0
def query_info(query_id):
    """
    Gather information about the query identified by the given
    query_id and store that in a JSON file.

    Parameters:
        query_id - id of the query for which info has to be gathered
    """

    if env.host not in fabricapi.get_coordinator_role():
        return

    err_msg = 'Unable to retrieve information. Please check that the ' \
              'query_id is correct, or check that server is up with ' \
              'command: server status'
    req = get_request(request_url(QUERY_REQUEST_EXT + query_id), err_msg)
    query_info_file_name = os.path.join(TMP_PRESTO_DEBUG, 'query_info_' + query_id + '.json')

    try:
        os.makedirs(TMP_PRESTO_DEBUG)
    except OSError:
        if not os.path.isdir(TMP_PRESTO_DEBUG):
            raise

    with open(query_info_file_name, 'w') as out_file:
        out_file.write(json.dumps(req.json(), indent=4))

    print('Gathered query information in file: ' + query_info_file_name)
Exemple #2
0
def query_info(query_id):
    """
    Gather information about the query identified by the given
    query_id and store that in a JSON file.

    Parameters:
        query_id - id of the query for which info has to be gathered
    """

    if env.host not in fabricapi.get_coordinator_role():
        return

    err_msg = 'Unable to retrieve information. Please check that the ' \
              'query_id is correct, or check that server is up with ' \
              'command: server status'
    req = get_request(request_url(QUERY_REQUEST_EXT + query_id), err_msg)
    query_info_file_name = os.path.join(TMP_PRESTO_DEBUG, 'query_info_' + query_id + '.json')

    try:
        os.makedirs(TMP_PRESTO_DEBUG)
    except OSError:
        if not os.path.isdir(TMP_PRESTO_DEBUG):
            raise

    with open(query_info_file_name, 'w') as out_file:
        out_file.write(json.dumps(req.json(), indent=4))

    print('Gathered query information in file: ' + query_info_file_name)
def file_get(remote_path, local_path):
    path_with_host_name = os.path.join(local_path, env.host)

    if not os.path.exists(path_with_host_name):
        os.makedirs(path_with_host_name)

    _LOGGER.debug('local path used ' + path_with_host_name)

    if exists(remote_path, True):
        get(remote_path, path_with_host_name, True)
    else:
        warn('remote path ' + remote_path + ' not found on ' + env.host)
Exemple #4
0
def get_files(remote_path, local_path):
    path_with_host_name = os.path.join(local_path, env.host)

    if not os.path.exists(path_with_host_name):
        os.makedirs(path_with_host_name)

    _LOGGER.debug('local path used ' + path_with_host_name)

    try:
        get(remote_path, path_with_host_name, use_sudo=True)
    except SystemExit:
        warn('remote path ' + remote_path + ' not found on ' + env.host)
Exemple #5
0
def file_get(remote_path, local_path):
    path_with_host_name = os.path.join(local_path, env.host)

    if not os.path.exists(path_with_host_name):
        os.makedirs(path_with_host_name)

    _LOGGER.debug('local path used ' + path_with_host_name)

    if exists(remote_path, True):
        get(remote_path, path_with_host_name, True)
    else:
        warn('remote path ' + remote_path + ' not found on ' + env.host)
Exemple #6
0
def get_files(remote_path, local_path):
    path_with_host_name = os.path.join(local_path, env.host)

    if not os.path.exists(path_with_host_name):
        os.makedirs(path_with_host_name)

    _LOGGER.debug('local path used ' + path_with_host_name)

    try:
        get(remote_path, path_with_host_name, use_sudo=True)
    except SystemExit:
        warn('remote path ' + remote_path + ' not found on ' + env.host)
Exemple #7
0
def system_info():
    """
    Gather system information like nodes in the system, presto
    version, presto-admin version, os version etc.
    """
    if env.host not in fabricapi.get_coordinator_role():
        return
    err_msg = 'Unable to access node information. ' \
              'Please check that server is up with command: server status'
    req = get_request(request_url(NODES_REQUEST_EXT), err_msg)

    downloaded_sys_info_loc = os.path.join(TMP_PRESTO_DEBUG, "sysinfo")
    try:
        os.makedirs(downloaded_sys_info_loc)
    except OSError:
        if not os.path.isdir(downloaded_sys_info_loc):
            raise

    node_info_file_name = os.path.join(downloaded_sys_info_loc,
                                       'node_info.json')
    with open(node_info_file_name, 'w') as out_file:
        out_file.write(json.dumps(req.json(), indent=4))

    _LOGGER.debug('Gathered node information in file: ' + node_info_file_name)

    catalog_file_name = os.path.join(downloaded_sys_info_loc,
                                     'catalog_info.txt')
    client = PrestoClient(env.host, env.user)
    catalog_info = get_catalog_info_from(client)

    with open(catalog_file_name, 'w') as out_file:
        out_file.write(catalog_info + '\n')

    _LOGGER.debug('Gathered catalog information in file: ' + catalog_file_name)

    execute(get_catalog_configs, downloaded_sys_info_loc, roles=env.roles)
    execute(get_system_info, downloaded_sys_info_loc, roles=env.roles)

    make_tarfile(OUTPUT_FILENAME_FOR_SYS_INFO, downloaded_sys_info_loc)
    print 'System info archive created: ' + OUTPUT_FILENAME_FOR_SYS_INFO
Exemple #8
0
def system_info():
    """
    Gather system information like nodes in the system, presto
    version, presto-admin version, os version etc.
    """
    if env.host not in fabricapi.get_coordinator_role():
        return
    err_msg = 'Unable to access node information. ' \
              'Please check that server is up with command: server status'
    req = get_request(request_url(NODES_REQUEST_EXT), err_msg)

    downloaded_sys_info_loc = os.path.join(TMP_PRESTO_DEBUG, "sysinfo")
    try:
        os.makedirs(downloaded_sys_info_loc)
    except OSError:
        if not os.path.isdir(downloaded_sys_info_loc):
            raise

    node_info_file_name = os.path.join(downloaded_sys_info_loc, 'node_info.json')
    with open(node_info_file_name, 'w') as out_file:
        out_file.write(json.dumps(req.json(), indent=4))

    _LOGGER.debug('Gathered node information in file: ' + node_info_file_name)

    conn_file_name = os.path.join(downloaded_sys_info_loc,
                                  'connector_info.txt')
    client = PrestoClient(env.host, env.user)
    conn_info = get_connector_info_from(client)

    with open(conn_file_name, 'w') as out_file:
        out_file.write(conn_info + '\n')

    _LOGGER.debug('Gathered connector information in file: ' + conn_file_name)

    execute(get_connector_configs, downloaded_sys_info_loc, roles=env.roles)
    execute(get_system_info, downloaded_sys_info_loc, roles=env.roles)

    make_tarfile(OUTPUT_FILENAME_FOR_SYS_INFO, downloaded_sys_info_loc)
    print 'System info archive created: ' + OUTPUT_FILENAME_FOR_SYS_INFO