Example #1
0
def report():
    basename = os.path.basename(sys.argv[0])

    parser = argparse.ArgumentParser(
        prog=basename,
        description='''A statistics reporting utility.  Use to print
                            out information about what happened during a run.
                            Takes as an argument previously ingested run
                            information one of the ingest utilities  in
                            a named database.''',
        epilog='''example:
report.py -H kaboom.ncsa.illinois.edu -p 3303 -d srp_2013_0601_140432 -S''')
    parser.add_argument("-H",
                        "--host",
                        action="store",
                        default=None,
                        dest="host",
                        help="mysql server host",
                        type=str,
                        required=True)
    parser.add_argument("-p",
                        "--port",
                        action="store",
                        default=3306,
                        dest="port",
                        help="mysql server port",
                        type=int)
    parser.add_argument("-d",
                        "--database",
                        action="store",
                        default=None,
                        dest="database",
                        help="database name",
                        type=str,
                        required=True)
    parser.add_argument("-I",
                        "--submits-per-interval",
                        action="store_true",
                        default=None,
                        dest="submits",
                        help="number of submits to queue per interval")
    parser.add_argument("-S",
                        "--slots-used-each-second",
                        action="store_true",
                        default=None,
                        dest="slots",
                        help="slots used each second")

    parser.add_argument("-N",
                        "--slots-used-each-interval",
                        type=int,
                        default=-1,
                        dest="interval",
                        help="slots used each interval")

    parser.add_argument("-L",
                        "--local-time-zone",
                        action="store_true",
                        default=False,
                        dest="localTimeZone",
                        help="output dates converted to local time zone")

    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        dest="verbose",
                        help="verbose")

    args = parser.parse_args()

    host = args.host
    port = args.port
    database = args.database

    #
    # get database authorization info
    #
    dbAuth = DbAuth()
    user = dbAuth.username(host, str(port))
    password = dbAuth.password(host, str(port))

    # connect to the database
    dbm = DatabaseManager(host, port, user, password)

    dbm.execCommand0('use ' + database)

    # command line arguments
    values = None
    submitTimes = SubmissionTimes(dbm)
    entries = submitTimes.getEntries()
    r = Report(dbm, args.localTimeZone)
    if args.submits:
        submitsPerInterval = SubmitsPerInterval(dbm, 1)
        values = submitsPerInterval.getValues()
        r.writePerTimeIntervals(values)
    elif args.slots:
        slotsPerSecond = SlotsPerSecond(dbm, entries)
        values = slotsPerSecond.getValues()
        r.writePerTimeIntervals(values)
    elif args.interval > -1:
        slotsPerInterval = SlotsPerInterval(dbm, entries, args.interval)
        values = slotsPerInterval.getValues()
        r.writePerTimeIntervals(values)
    else:
        printSummary(r)
    dbm.close()
Example #2
0
                        "--verbose",
                        action="store_true",
                        dest="verbose",
                        help="verbose")

    args = parser.parse_args()

    host = args.host
    port = args.port
    database = args.database

    #
    # get database authorization info
    #

    dbAuth = DbAuth()
    user = dbAuth.username(host, str(port))
    password = dbAuth.password(host, str(port))

    # connect to the database
    dbm = DatabaseManager(host, port, user, password)

    # create the database if it doesn't exist
    if not dbm.dbExists(database):
        dbm.createDb(database)

    # create the LogIngestor, which creates all the tables, and will
    # be used to consolidate file information
    logIngestor = LogIngestor(dbm, database)

    # go through the list of files and ingest them, ignoring any