Determine why job is pending

Use lsb_pendreason() to write a program to print out the reason why a job is in pending status.

lsb_pendreason()

char *lsb_pendreason (int numReasons, int *rsTb, 
                      struct jobInfoHead *jInfoH,
                      struct loadIndexLog *ld, int clusterId)
  • rsTb is a reason table in which each entry contains one pending reason.

  • numReasons is an integer representing the number of reasons in the table.

jobInfoHead structure

struct jobInfoHead is returned by the lsb_openjobinfo_a() function. It is defined as follow:

struct jobInfoHead {
    int   numJobs;
    LS_LONG_INT *jobIds;
    int   numHosts;    char  **hostNames;
    int   numClusters;
    char  **clusterNames;
    int   *numRemoteHosts;
    char  ***remoteHosts;};

ld is the same struct as used in the above lsb_suspreason() function call.

This program is similar but different from the above program for displaying the suspending reason. Use lsb_openjobinfo_a() to open the job information connection, instead of lsb_openjobinfo(). Because the struct jobInfoHead is needed as one of the arguments when calling the function lsb_pendreason().

struct jobInfoHead *lsb_openjobinfo(jobId, jobName, user, queue, host, options);

The following initialization and code fragment show how to display the pending reason using lsb_pendreason():

/* initialization */
char *pendreason;
struct loadIndexLog *indices =(struct loadIndexLog *) malloc(sizeof(struct loadIndexLog));
struct jobInfoHead *jInfoH = (struct jobInfoHead *) malloc(sizeof(struct jobInfoHead));
/* open the job information connection with mbatchd */
jInfoH = lsb_openjobinfo_a(0, NULL, user, NULL, NULL, options);
/* gets the total number of pending job, exits if failure */
if (jInfoH==NULL) {
    lsb_perror("lsb_openjobinfo");
    exit(-1);
}
/* get the list of all load index names */
indices->name = getindexlist(&indices->nIdx);
/* get and print out the pending reasons */
pendreason = lsb_pendreason(job->numReasons,job-> reasonTb,jInfoH,indices,clusterId);
printf("%s\n",pendreason);
Tip:

Use ls_loadinfo() to get the list of all load index names.