Ejemplo n.º 1
0
def Uptime():
    # set some reasonable defaults
    archdir = SiteDep.get('RawArchive', 'archdir')
    scid = SiteDep.getint('DEFAULT', 'scid')
    tnc_dbi = SiteDep.get('DEFAULT', 'dbi')
    dbrel = SiteDep.get('DEFAULT', 'dbrel')
    run = None
    verbose = None
    csv = None
    mode_report = None
    saa_report = None
    lpa_report = None
    lci_report = None
    pwr_report = None
    t0str = '-10 minutes'
    t1str = 'now'
    tpad = 5.0
    uhandlers = [None, None, UptimeHandler(label="Uptime")]
    modes = range(0, 13)
    lpastates = range(0, 4)
    lcistates = range(0, 4)

    # get the command-line arguments
    if len(sys.argv) == 1:
        usage()
        return
    else:
        try:
            opts, args = getopt.getopt(sys.argv[1:], 'b:e:r::vhmwspcax', \
                                       ['beg=','end=','run=',
                                        'verbose','help','mode','saa','lpa','lci','pwr','all','exc'])
        except getopt.GetoptError, e:
            print e
            print 'try "Uptime.py --help" for usage information.'
            return
Ejemplo n.º 2
0
def SsrUsage():
    # set some reasonable defaults
    archdir = SiteDep.get('RawArchive', 'archdir')
    scid = SiteDep.getint('DEFAULT', 'scid')
    tnc_dbi = SiteDep.get('DEFAULT', 'dbi')
    dbrel = SiteDep.get('DEFAULT', 'dbrel')
    run = None
    verbose = None
    t0str = '-10 minutes'
    t1str = 'now'
    tpad = 5.0
    uhandlers = [None, None, SsrUsageHandler(label="Total")]

    # get the command-line arguments
    if len(sys.argv) == 1:
        usage()
        return
    else:
        try:
            opts, args = getopt.getopt(sys.argv[1:], 'b:e:r:dwvh', \
                                       ['beg=','end=','run=',
                                        'day','week','verbose','help'])
        except getopt.GetoptError, e:
            print e
            print 'try "SsrUsage.py --help" for usage information.'
            return
Ejemplo n.º 3
0
    for h in uhandlers:
        if h:
            h.setVerbose(verbose)
            h.setModes(modes, mode_report=True)
            h.setSaa(saa_report)
            h.setLpa(lpastates, lpa_report)
            h.setLci(lcistates, lci_report)
            h.setPwr(pwr_report)
            h.setCsv(csv)

    # if a run has been specified, retrieve the start/end times
    # from the database
    if run is not None:
        t0str, t1str = utility.getRunSpan(
            run, SiteDep.get('MakeRetDef', 'runs_dbi'))
        if t0str is None:
            print 'Uptime: run %09d not found' % run
            return
        print 'Uptime: retrieving data for run %09d %s --> %s' %\
              ( run, t0str, t1str )

    # get double-precision reps of the timespan endpoints
    t0, t1 = ProductSpan.getspan(t0str, t1str)

    # back up the start-time of the retrieval so we have values at t0
    t0ret = t0 - tpad

    # extend the end-time of the retrieval to allow sampled output to end at
    # the user-specified time
    t1ret = t1 + tpad