By providing a list of load index names to an LSLIB function, you can get the load information about the specified load indices.
The following example shows how you can display the values of the external load indices. This program uses ls_loadinfo():
The parameters for this routine are:
char *resreq; Resource requirementint *numhosts; Return parameter, number of hosts returnedint options; Host and load selection optionschar *fromhost; Used only if DFT_FROMTYPE is set in optionschar **hostlist; A list of candidate hosts for selectionint listsize; Number of hosts in hostlistchar ***namelist; Input/output parameter -- load index name list
ls_loadinfo() is similar to ls_load() except that ls_loadinfo() allows an application to supply both a list of load indices and a list of candidate hosts. If both of namelist and hostlist are NULL, then it operates in the same way as ls_load() function.
The parameter namelist allows an application to specify a list of load indices of interest. The function then returns only the specified load indices. On return, this parameter is modified to point to another name list that contains the same set of load index names. This load index is in a different order to reflect the mapping of index names and the actual load values returned in the hostLoad array:
#include <stdio.h>#include <lsf/lsf.h>/*include the header file with the getIndexList function here*/main(){struct hostLoad *load;char **loadNames;int numIndx;int numUsrIndx;int nHosts;int i;int j;loadNames = getIndexList(&numIndx);if (loadNames == NULL) {ls_perror("Unable to get load index names\n");exit(-1);}numUsrIndx = numIndx - 11; /* this is the total num ofsite defined indices*/if (numUsrIndx == 0) {printf("No external load indices defined\n");exit(-1);}loadNames += 11; /* skip the 11 built-in load index names */load = ls_loadinfo(NULL, &nHosts, 0, NULL, NULL, 0, &loadNames);if (load == NULL) {ls_perror("ls_loadinfo");exit(-1);}printf("Report on external load indices\n");for (i=0; i<nHosts; i++) {printf("Host %s:\n", load[i].hostName);for (j=0; j<numUsrIndx; j++)printf("index name: %s, value %5.0f\n",loadNames[j], load[i].li[j]);}}