Esempio n. 1
0
def parseCommandLine():
    usage   = "Usage: %prog [options] command [args]"
    parser  = OptionParser(usage=usage)
    
    parser.add_option("-f", "--form", action="store_true", dest="show_form", 
        default=False, help="Include user-submitted input form in results")
    
    parser.add_option("-s", "--stack", default=None, type="string",
        action="store", dest="stack", help="stack to pull logs from")
    
    parser.add_option("-u", "--user-id", dest="user_id", 
        default=None, type="string", help="Filter results on user id")
    
    parser.add_option("-m", "--method", dest="method", 
        default=None, type="string", help="Request method (POST, GET, or ASYNC)")
    
    parser.add_option("-l", "--limit", dest="limit", 
        default=10, type="int", help="Limit number of results returned")
    
    parser.add_option("-p", "--path", dest="path", 
        default=None, type="string", help="Filter results on url path")
    
    parser.add_option("-c", "--code", dest="code", 
        default=None, type="int", help="Filter results on status code")

    parser.add_option("-S", "--slow", dest="slow", action="store",
        default=None, type="int", help="Filter results that took longer than n seconds")


    (options, args) = parser.parse_args()
    
    if is_ec2() or options.stack:
        logger_nodes = get_db_nodes('logger')
        if len(logger_nodes) == 0:
            print("Warning: No instances exist on stack 'logger'")
            return options
        if options.stack is None:
            options.stack = 'bowser'

    return options
Esempio n. 2
0
def parseCommandLine():
    usage = "Usage: %prog [options] command [args]"
    version = "%prog " + __version__
    parser = OptionParser(usage=usage, version=version)

    parser.add_option(
        "-d",
        "--headers",
        action="store_true",
        dest="show_headers",
        default=False,
        help="Include HTTP headers in results",
    )

    parser.add_option(
        "-f",
        "--form",
        action="store_true",
        dest="show_form",
        default=False,
        help="Include user-submitted input form in results",
    )

    parser.add_option(
        "-o", "--output", action="store_true", dest="show_output", default=False, help="Include JSON result in results"
    )

    parser.add_option(
        "-e", "--errors", action="store_true", dest="show_errors", default=False, help="Only display errors in results"
    )

    parser.add_option(
        "-v", "--verbose", action="store_true", dest="verbose", default=False, help="Set verbosity of logs"
    )

    parser.add_option(
        "-s", "--stack", default=None, type="string", action="store", dest="stack", help="stack to pull logs from"
    )

    parser.add_option("-u", "--user-id", dest="user_id", default=None, type="string", help="Filter results on user id")

    parser.add_option("-i", "--request-id", dest="request_id", default=None, type="string", help="Filter on request id")

    parser.add_option(
        "-m", "--method", dest="method", default=None, type="string", help="Request method (POST, GET, or ASYNC)"
    )

    parser.add_option("-l", "--limit", dest="limit", default=10, type="int", help="Limit number of results returned")

    parser.add_option("-p", "--path", dest="path", default=None, type="string", help="Filter results on url path")

    parser.add_option(
        "-t",
        "--severity",
        dest="severity",
        default=None,
        type="string",
        help="Filter results on severity (debug, info, warning, error, critical)",
    )

    parser.add_option("-c", "--code", dest="code", default=None, type="int", help="Filter results on status code")

    parser.add_option(
        "-S",
        "--slow",
        dest="slow",
        action="store",
        default=None,
        type="int",
        help="Filter results that took longer than n seconds",
    )

    (options, args) = parser.parse_args()

    if is_ec2() or options.stack:
        logger_nodes = get_db_nodes("logger")
        if len(logger_nodes) == 0:
            print ("Warning: No instances exist on stack 'logger'")
            return options
        instance_name = "%s.%s" % (logger_nodes[0]["stack"], logger_nodes[0]["name"])
        utils.init_log_db_config(instance_name)
        if options.stack is None:
            options.stack = get_stack().instance.stack

    return options