Esempio n. 1
0
def execute():
    config = ConfigReader()
    dbInput = checkConfigForDB(config)
    dbBackend = opentsdb(dbInput)
    CURRENT_TIME = int(time.time())
    sites = []
    with open('sites', 'r') as fd:
        sites = fd.readlines()
    for host in sites:
        host = host.strip()
        newfile = "root://cmsxrootd.fnal.gov//store/test/xrootd/%s/store/mc/SAM/GenericTTbar/AODSIM/CMSSW_9_2_6_91X_mcRun1_realistic_v2-v1/00000/A64CCCF2-5C76-E711-B359-0CC47A78A3F8.root" % host
        outfile = 'output/%s-%s' % (host, CURRENT_TIME)
        cmd = "timeout 300 xrdcp --debug 3 -f %s %s" % (newfile, "/dev/null")
        print cmd
        streamdata = ""
        try:
            out = Popen(cmd.split(),
                        stdin=PIPE,
                        stdout=PIPE,
                        stderr=STDOUT,
                        close_fds=True)
            streamdata = out.communicate()[0]
            rc = out.returncode
            t = rc, streamdata
        except CalledProcessError as e:
            t = e.returncode, e.message
        if int(t[0] != 0):
            writelog(streamdata, outfile)
        print(host)
        dbBackend.sendMetric('xrd.redir.status', t[0], {
            'myhost': host,
            'timestamp': CURRENT_TIME
        })
    dbBackend.stopWriter()
Esempio n. 2
0
def execute(logger):
    config = ConfigReader()
    dbInput = checkConfigForDB(config)
    dbBackend = opentsdb(dbInput)
    startTime = int(time.time())
    logger.info('Running Main')
    main(startTime, config, dbBackend, logger)
    dbBackend.stopWriter()  # Flush out everything what is left.
    endTime = int(time.time())
    totalRuntime = endTime - startTime
    logger.info('StartTime: %s, EndTime: %s, Runtime: %s' % (startTime, endTime, totalRuntime))
Esempio n. 3
0
def execute(logger):
    config = ConfigReader()
    dbInput = checkConfigForDB(config)
    dbBackend = opentsdb(dbInput)
    startTime = int(time.time())
    logger.info('Running Main')
    main(startTime, config, dbBackend, logger)
    logger.info('Getting dir stats')
    allDirStats = getDirStats('/store', logger)
    publishMetrics(dbBackend, 'hadoop.spaceUsage.storeSpace', len('/store/'), allDirStats, startTime, logger)
    allDirStats = getDirStats('/store/user/', logger)
    publishMetrics(dbBackend, 'hadoop.spaceUsage.storeuserSpace', len('/store/user/'), allDirStats, startTime, logger)
    allDirStats = getDirStats('/store/group/', logger)
    publishMetrics(dbBackend, 'hadoop.spaceUsage.storegroupSpace', len('/store/group/'), allDirStats, startTime, logger)
    dbBackend.stopWriter()  # Flush out everything what is left.
    endTime = int(time.time())
    totalRuntime = endTime - startTime
    logger.info('StartTime: %s, EndTime: %s, Runtime: %s' % (startTime, endTime, totalRuntime))
Esempio n. 4
0
def execute(logger):
    config = ConfigReader()
    dbInput = checkConfigForDB(config)
    dbBackend = opentsdb(dbInput)
    redirector = ""
    if config.hasSection('xcache'):
        redirector = config.getOptions('xcache')['redirector']
    if not redirector:
        raise Exception('Redirector not set in configuration')
    startTime = int(time.time())
    logger.info('Running Main')
    currdate = datetime.now()
    preparefiles(currdate, logger)
    main(currdate, redirector, dbBackend, logger)
    dbBackend.stopWriter()  # Flush out everything what is left.
    endTime = int(time.time())
    totalRuntime = endTime - startTime
    logger.info('StartTime: %s, EndTime: %s, Runtime: %s' %
                (startTime, endTime, totalRuntime))
Esempio n. 5
0
def execute():
    config = ConfigReader()
    dbInput = checkConfigForDB(config)
    dbBackend = opentsdb(dbInput)
    CURRENT_TIME = int(time.time())
    sites = []
    with open('sites', 'r') as fd:
        sites = fd.readlines()
    for host in sites:
        host = host.strip()
        newfile = "root://cmsxrootd.fnal.gov//store/test/xrootd/%s/store/mc/SAM/GenericTTbar/AODSIM/CMSSW_9_2_6_91X_mcRun1_realistic_v2-v1/00000/A64CCCF2-5C76-E711-B359-0CC47A78A3F8.root" % host
        cmd = "timeout 180 xrdcp -f %s %s" % (newfile, "/dev/null")
        print cmd
        try:
            out = check_output(cmd.split())
            t = 0, out
        except CalledProcessError as e:
            t = e.returncode, e.message
        print t, host
        dbBackend.sendMetric('xrd.redir.status', t[0], {
            'myhost': host,
            'timestamp': CURRENT_TIME
        })
    dbBackend.stopWriter()