Ejemplo n.º 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(QUERY_REQUEST_URL + query_id, err_msg)

    query_info_file_name = os.path.join(TMP_PRESTO_DEBUG,
                                        'query_info_' + query_id + '.json')

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    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)
Ejemplo n.º 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')

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    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)
Ejemplo n.º 3
0
def logs():
    """
    Gather all the server logs and presto-admin log and create a tar file.
    """

    _LOGGER.debug('LOG directory to be archived: ' + REMOTE_PRESTO_LOG_DIR)

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    downloaded_logs_location = os.path.join(TMP_PRESTO_DEBUG, "logs")

    if not os.path.exists(downloaded_logs_location):
        os.mkdir(downloaded_logs_location)

    print 'Downloading logs from all the nodes...'
    execute(file_get,
            REMOTE_PRESTO_LOG_DIR,
            downloaded_logs_location,
            roles=env.roles)

    copy_admin_log(downloaded_logs_location)

    make_tarfile(OUTPUT_FILENAME_FOR_LOGS, downloaded_logs_location)
    print 'logs archive created: ' + OUTPUT_FILENAME_FOR_LOGS
Ejemplo n.º 4
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)

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    downloaded_sys_info_loc = os.path.join(TMP_PRESTO_DEBUG, "sysinfo")
    node_info_file_name = os.path.join(downloaded_sys_info_loc,
                                       'node_info.json')

    if not os.path.exists(downloaded_sys_info_loc):
        os.mkdir(downloaded_sys_info_loc)

    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_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
Ejemplo n.º 5
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)

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    downloaded_sys_info_loc = os.path.join(TMP_PRESTO_DEBUG, "sysinfo")
    node_info_file_name = os.path.join(downloaded_sys_info_loc,
                                       'node_info.json')

    if not os.path.exists(downloaded_sys_info_loc):
        os.mkdir(downloaded_sys_info_loc)

    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_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
Ejemplo n.º 6
0
def logs():
    """
    Gather all the server logs and presto-admin log and create a tar file.
    """

    _LOGGER.debug('LOG directory to be archived: ' + REMOTE_PRESTO_LOG_DIR)

    if not os.path.exists(TMP_PRESTO_DEBUG):
        os.mkdir(TMP_PRESTO_DEBUG)

    downloaded_logs_location = os.path.join(TMP_PRESTO_DEBUG, "logs")

    if not os.path.exists(downloaded_logs_location):
        os.mkdir(downloaded_logs_location)

    print 'Downloading logs from all the nodes...'
    execute(file_get, REMOTE_PRESTO_LOG_DIR,
            downloaded_logs_location, roles=env.roles)

    copy_admin_log(downloaded_logs_location)

    make_tarfile(OUTPUT_FILENAME_FOR_LOGS, downloaded_logs_location)
    print 'logs archive created: ' + OUTPUT_FILENAME_FOR_LOGS