This API gives access to LoadLeveler objects and allows the retrieval of specific data from those objects.
from pyloadl import * version = ll_version() # # Data Access API functions # query = ll_query( JOBS|MACHINES|CLUSTER|WLMSTAT|MATRIX|CLASSES|RESERVATIONS| MCLUSTERS|BLUE_GENE|FAIRSHARE) return = ll_set_request( query,QUERY_ALL| QUERY_JOBID| QUERY_STEPID| QUERY_GROUP| QUERY_CLASS| QUERY_HOST| QUERY_STARTDATE| QUERY_ENDDATE| QUERY_PROCID| QUERY_RESERVATION_ID, filter_list, ALL_DATA|Q_LINE|STATUS_LINE ) object ,num_objs, err_code = ll_get_objs( query, LL_STARTD|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 )
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 :
ll_query is the first call you make to access the API, it establishes the type of information you receive.
query = ll_query( JOBS | MACHINES | CLUSTER | WLMSTAT | MATRIX | CLASSES | RESERVATIONS | MCLUSTERS | BLUE_GENE | FAIRSHARE )
ll_set_request is used to determine the range of data returned by ll_get_objs.
return = ll_set_request(query, QueryFlags, ObjectFilter, DataFilter)
Parameters
The object returned from ll_query
The permissable Query Flags depends on the type of query being made., the flags are :
They can be used with the following query types:
Query Type | Permitted Flags |
---|---|
JOBS | QUERY_ALL QUERY_JOBID QUERY_STEPID QUERY_USER QUERY_GROUP QUERY_CLASS QUERY_HOST QUERY_STARTDATE QUERY_ENDDATE QUERY_PROCID QUERY_RESERVATION_ID |
MACHINES | QUERY_ALL QUERY_HOST |
CLUSTER | QUERY_ALL |
CLASSES | QUERY_ALL QUERY_CLASS |
WLMSTAT | QUERY_STEPID |
MATRIX | QUERY_ALL QUERY_HOST |
RESERVATIONS | QUERY_ALL QUERY_USER QUERY_GROUP QUERY_HOST QUERY_RESERVATION_ID |
MCLUSTERS | QUERY_ALL |
BLUE_GENE | QUERY_ALL QUERY_BG_BASE_PARTITION QUERY_BG_PARTITION |
FAIRSHARE | QUERY_ALL QUERY_USER QUERY_GROUP |
Specifies the search criteria:
Query Flag | Filter |
---|---|
QUERY_ALL | None |
QUERY_JOBID | List of job IDs eg ["host.jobid1", "host.jobid2"] |
QUERY_STEPID | List of step IDs eg ["host.jobid.stepid"] |
QUERY_USER | List of user IDs eg ["mike", "mark", "mary"] |
QUERY_CLASS | List of LoadLeveler class names. |
QUERY_GROUP | List of LoadLeveler group names. |
QUERY_HOST | List of LoadLeveler host names. |
QUERY_STARTDATE or QUERY_ENDDATE | two start dates or two end dates having the format MM/DD/YYYY eg ["01/14/2003", "02/23/2003"]. |
QUERY_PROCID | List containing a single process id, this is automatically terminated with a NULL by PyLoadL. eg ["procid"] |
QUERY_RESERVATION_ID | List containing a single reservation id. |
QUERY_LOCAL | N/A |
QUERY_BG_JOB | Query by bluegene type jobs only. List of job IDs eg ["host.jobid1", "host.jobid2"] |
QUERY_BG_BASE_PARTITION | List of BG Base Partitions, ["all"] for all base partitions.` |
QUERY_BG_PARTITION | List of BG Partitions, ["all"] for all partitions. |
Filters the amount of data you get back from the query. Permitted values are:
This is used to reset the request associated with a query object, you use it if you want to do another ll_set_request using different parameters.
return = ll_reset_request(query)
Sends a query request to LoadLeveler
object, num_objs, err_code = ll_get_objs( query, query_daemon, host )
Returns a LL_element object, the number of query objects and an error code if one occurred. Possible error values are :
Parameters
data = ll_get_data(element, LLAPI specification)
This call differs from the IBM documentation, the data you request is returned as the return value and not as a third parameter eg
load_avg = get_data(machine, LL_MachineLoadAverage) # Returns an integer mach_list = get_data(machine, LL_MachineStepList) # Returns a list of strings
To know what you are getting you really need to know about the LoadLeveler Job Object Model. All of this is in the IBM LoadLeveler for AIX 5L: Using and Administering reference guide and html.
enum types
Returns from some query types may be, in C terms, enumerated types. In PyLoadL these all return as integers. Return values are shown below:
SHARED, NOT_SHARED, SLICE_NOT_SHARED
NO_HOLD, HOLDTYPE_USER, HOLDTYPE_SYSTEM, HOLDTYPE_USERSYS
STATE_IDLE, STATE_PENDING, STATE_STARTING, STATE_RUNNING, STATE_COMPLETE_PENDING, STATE_REJECT_PENDING, STATE_REMOVE_PENDING, STATE_VACATE_PENDING, STATE_COMPLETED, STATE_REJECTED, STATE_REMOVED, STATE_VACATED, STATE_CANCELED, STATE_NOTRUN, STATE_TERMINATED, STATE_UNEXPANDED, STATE_SUBMISSION_ERR, STATE_HOLD, STATE_DEFERRED, STATE_NOTQUEUED, STATE_PREEMPTED, STATE_PREEMPT_PENDING, STATE_RESUME_PENDING
Returns the next object from the query object.
job = ll_next_obj(query)
Frees up the the space taken by the ll_get_objs routine for the LoadLeveler Data. Since there is probably an awful lot of this this is a very important call.
return = ll_free_objs(query)
Frees the query object itself, this is the last LoadLeveler action.
return = ll_deallocate(query)
the LoadLeveler page the WorkLoad Management page the Error Handling page
IBM LoadLeveler for AIX 5L: Using and Administering