def display(eventrec):
    """
    display event record
    """
    if eventrec.type == lsf.EVENT_JOB_NEW:
        jobid = eventrec.eventLog.jobNewLog.jobId
        fromHost = eventrec.eventLog.jobNewLog.fromHost
        queue = eventrec.eventLog.jobNewLog.queue
        cwd = eventrec.eventLog.jobNewLog.cwd
        print("EVENT_JOB_NEW jobid<%d>, fromHost<%s>, to Queue<%s>, CWD<%s>" %(jobid, fromHost, queue, cwd))
    elif eventrec.type == lsf.EVENT_JOB_START:
        numHosts = eventrec.eventLog.jobStartLog.numExHosts
        execHosts = eventrec.eventLog.jobStartLog.execHosts
        hoststr = ""
        for i in range(0,numHosts):
            hoststr += lsf.stringArray_getitem(execHosts, i) + ""
        print("EVENT_JOB_START execHosts<%s>" %(hoststr))
    elif eventrec.type == lsf.EVENT_JOB_FORCE:
        username = eventrec.eventLog.jobForceRequestLog.userName
        jobid = eventrec.eventLog.jobForceRequestLog.jobId
        numhosts = eventrec.eventLog.jobForceRequestLog.numExecHosts
        exechosts = eventrec.eventLog.jobForceRequestLog.execHosts
        hoststr = ""
        for i in range(0,numhosts):
            hoststr += lsf.stringArray_getitem(exechosts, i) + ""
        print("EVENT_JOB_FORCE jobid<%d>, execHost<%s>, username<%s>" %(jobid, hoststr, username))

    else:
        print("event type is %d" %(eventrec.type))
Ejemplo n.º 2
0
def display(eventrec):
    """
    display event record
    """
    if eventrec.type == lsf.EVENT_JOB_NEW:
        jobid = eventrec.eventLog.jobNewLog.jobId
        fromHost = eventrec.eventLog.jobNewLog.fromHost
        queue = eventrec.eventLog.jobNewLog.queue
        cwd = eventrec.eventLog.jobNewLog.cwd
        print("EVENT_JOB_NEW jobid<%d>, fromHost<%s>, to Queue<%s>, CWD<%s>" %
              (jobid, fromHost, queue, cwd))
    elif eventrec.type == lsf.EVENT_JOB_START:
        numHosts = eventrec.eventLog.jobStartLog.numExHosts
        execHosts = eventrec.eventLog.jobStartLog.execHosts
        hoststr = ""
        for i in range(0, numHosts):
            hoststr += lsf.stringArray_getitem(execHosts, i) + ""
        print("EVENT_JOB_START execHosts<%s>" % (hoststr))
    elif eventrec.type == lsf.EVENT_JOB_FORCE:
        username = eventrec.eventLog.jobForceRequestLog.userName
        jobid = eventrec.eventLog.jobForceRequestLog.jobId
        numhosts = eventrec.eventLog.jobForceRequestLog.numExecHosts
        exechosts = eventrec.eventLog.jobForceRequestLog.execHosts
        hoststr = ""
        for i in range(0, numhosts):
            hoststr += lsf.stringArray_getitem(exechosts, i) + ""
        print("EVENT_JOB_FORCE jobid<%d>, execHost<%s>, username<%s>" %
              (jobid, hoststr, username))

    else:
        print("event type is %d" % (eventrec.type))
Ejemplo n.º 3
0
def display(eventrec):
    '''
    collect event records
    '''
    idx = eventrec.eventLog.jobFinishLog.idx
    jobId = eventrec.eventLog.jobFinishLog.jobId
    queue = eventrec.eventLog.jobFinishLog.queue
    avgMem = eventrec.eventLog.jobFinishLog.avgMem
    resReq = eventrec.eventLog.jobFinishLog.resReq
    options = eventrec.eventLog.jobFinishLog.options
    jStatus = eventrec.eventLog.jobFinishLog.jStatus
    maxRMem = eventrec.eventLog.jobFinishLog.maxRMem
    jobName = eventrec.eventLog.jobFinishLog.jobName
    endTime = eventrec.eventLog.jobFinishLog.endTime
    runTime = eventrec.eventLog.jobFinishLog.runTime
    cpuTime = eventrec.eventLog.jobFinishLog.cpuTime
    runLimit = eventrec.eventLog.jobFinishLog.runLimit
    userName = eventrec.eventLog.jobFinishLog.userName
    exitInfo = eventrec.eventLog.jobFinishLog.exitInfo
    termTime = eventrec.eventLog.jobFinishLog.termTime
    startTime = eventrec.eventLog.jobFinishLog.startTime
    exitStatus = eventrec.eventLog.jobFinishLog.exitStatus
    exceptMask = eventrec.eventLog.jobFinishLog.exceptMask
    numProcessors = eventrec.eventLog.jobFinishLog.numProcessors
    numExHosts = eventrec.eventLog.jobFinishLog.numExHosts

    #execHosts are an array, we can get array number from
    #numExHosts and iterate through the set to create an
    #execHosts (hosts) per job

    hosts = ""
    execHosts = eventrec.eventLog.jobFinishLog.execHosts
    for i in range(0, numExHosts):
        hosts += lsf.stringArray_getitem(execHosts, i) + " "

    # Some exit codes are special. A quick lookup.
    if exitStatus == 256:
        exitStatus = 1
    if exitStatus == 512:
        exitStatus = 0
    if exitStatus == 158:
        exitStatus = 30

    # some have bit shifts
    if exitStatus != 256 and exitStatus != 158 \
 and exitStatus != 512 and exitStatus > 255:
        exitStatus = bintrans(exitStatus)

    # lookup LSF kill reasons, where they exist
    if 1 <= exitInfo <= 26:
        exitInfo = whyexit(exitInfo)

    GMendTime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(endTime))

    mkmessage(idx, jobId, queue, avgMem, options, resReq, jStatus, \
     maxRMem, jobName, endTime, runTime, cpuTime, runLimit, \
     userName, exitInfo, termTime, startTime, exitStatus, \
     exceptMask, numProcessors, GMendTime, hosts)
Ejemplo n.º 4
0
print '\n Clustername: ', lsf.ls_getclustername(), '\n'

print '{0:15s} {1:20s} {2:20s} {3:5s} {4:4s}'.format('Hostname', 'Type',
                                                     'Model', 'Cores', 'Load')

for info in lsf.get_host_info():
    #Deal with the case when hostname contain "-".
    if '-' in info.hostName:
        load = lsf.get_host_load("hname=" + "'" + info.hostName + "'",
                                 lsf.R15M)
    else:
        load = lsf.get_host_load("hname=" + info.hostName, lsf.R15M)

    if load >= 65535:
        load = -1

    print '{0:15s} {1:20s} {2:20s} {3:5d} {4:4.2f}'.format(
        info.hostName, info.hostType, info.hostModel, info.cores, load)

    resources = ""
    index = 0
    if info.nRes > 0:
        while (True):
            item = lsf.stringArray_getitem(info.resources, index)
            if (item):
                resources += item + " "
                index += 1
            else:
                break
        print ' +--> Resources:', resources
Ejemplo n.º 5
0
print '{0:15s} {1:20s} {2:20s} {3:5s} {4:4s}'.format('Hostname', 'Type',
                                                     'Model', 'Cores', 'Load')

for info in lsf.get_host_info():
    #Deal with the case when hostname contain "-".
    if '-' in info.hostName:
        load = lsf.get_host_load("hname=" + "'" + info.hostName + "'", lsf.R15M)
    else:
        load = lsf.get_host_load("hname=" + info.hostName, lsf.R15M)
    
    if load >= 65535:
        load = -1

    print '{0:15s} {1:20s} {2:20s} {3:5d} {4:4.2f}'.format(info.hostName,
                                                           info.hostType,
                                                           info.hostModel,
                                                           info.cores,
                                                           load)

    resources = ""
    index = 0;
    if info.nRes > 0:
        while(1):
            item = lsf.stringArray_getitem(info.resources,index)
            if(item):
                resources += item +" "
                index += 1
            else:
               break;
        print ' +--> Resources:', resources