Data Access API

This API gives access to LoadLeveler objects and allows the retrieval of specific data from those objects.


SYNOPSIS


  from pyloadl import *
  
  version = ll_version()

  #
  # Data Access API functions
  #

 query = ll_query( JOBS|MACHINES|CLUSTER|WLMSTAT|MATRIX|CLASSES )

 return = ll_set_request( query,QUERY_ALL| QUERY_JOBID|
                                 QUERY_STEPID| QUERY_GROUP| 
			         QUERY_CLASS| QUERY_HOST| 
			         QUERY_STARTDATE| QUERY_ENDDATE| 
			         QUERY_PROCID, filter_list, ALL_DATA|Q_LINE|STATUS_LINE )
 
 object ,num_objs, err_code = ll_get_objs( query, LL_STARTED|LL_SCHEDD|LL_CM|LL_MASTER|
                              LL_STARTER|LL_HISTORY_FILE, hostname)
			      
 return = ll_reset_request( object )

 object = ll_next_obj( object )

 return = ll_free_objs( object )

 return = ll_deallocate( query )
 
 result = ll_get_data( object, LLAPI_Specification )
 


DESCRIPTION

A example of a script to output similar to the LoadLeveler llq command using PyLoadL is:


from pyloadl import *
from time import gmtime, strftime

stepstate = [
    "I", "P", "ST", "R",
    "CP", "XP", "RP",
    "VP", "C", "X", "RM",
    "V", "CA", "NR", "TX",
    "?", "SX", "H", "D",
    "NQ", "E", "EP",
    "MP" ]

#
# Query Job information
#

query = ll_query(JOBS)

retval = ll_set_request(query, QUERY_ALL, "", ALL_DATA)
job, num, err = ll_get_objs(query, LL_CM, "")

print "Id                        Owner      Submitted   ST PRI Class        Running On"
print "------------------------- ---------- ----------- -- --- ------------ -------------"

jobs_total = 0
jobs_run = 0
jobs_idle = 0
jobs_pending = 0
jobs_held = 0
jobs_preempt = 0

if num > 0:

        while PyCObjValid(job):

                # Get User Information

                cred  = ll_get_data(job, LL_JobCredential)
                owner = ll_get_data(cred, LL_CredentialUserName)a
		
                 sdate  = ll_get_data(job, LL_JobSubmitTime)
                 date = ""
                 if sdate != 0:
                         sdate = gmtime(sdate)
                         date = strftime("%m/%d %H:%M", sdate)
			 
                # Loop through all steps for this job

                step = ll_get_data(job, LL_JobGetFirstStep)
                while PyCObjValid(step):

                        jobs_total = jobs_total + 1

                        state  = ll_get_data(step, LL_StepState)
                        status = stepstate[state]

                        if status == "R":       jobs_run = jobs_run + 1
                        if status == "I":       jobs_idle = jobs_idle + 1
                        if status == "NQ":      jobs_pending = jobs_pending + 1
                        if status == "H":       jobs_held = jobs_held + 1
                        if status == "E":       jobs_preempt = jobs_preempt + 1

                        id     = ll_get_data(step, LL_StepID)
                        pri    = ll_get_data(step, LL_StepPriority)
                        jclass = ll_get_data(step, LL_StepJobClass)

                        machine = ""
                        machine_obj = ll_get_data(step, LL_StepGetFirstMachine)
                        if PyCObjValid(machine_obj):
                                machine = ll_get_data(machine_obj, LL_MachineName)

                        print "%-25s %-10s %-11s %-2s %-3d %-12s %-13s" % 
                                  (id, owner, date, status, pri, jclass, machine)

                        step = ll_get_data(job, LL_JobGetNextStep)

                job = ll_next_obj(query)

print "\n"
print "%d job step(s) in queue, %d waiting, %d pending, %d running, %d held, %d preempted" %
           ( jobs_total, jobs_idle, jobs_pending, jobs_run, jobs_held, jobs_preempt)

# Free and deallocate objects used by LoadLeveler

ll_free_objs(job)
ll_deallocate(query)


The Data Access API has the following functions:

The functions are called in the following order :



SEE ALSO

the LoadLeveler page the WorkLoad Management page the Error Handling page

IBM LoadLeveler for AIX 5L: Using and Administering