Since LSF allows a site to install an ELIM to collect additional load indices, the names and the total number of load indices are often dynamic and have to be found out at run time unless the application is only using the built-in load indices.
Below is an example routine that returns a list of all available load index names and the total number of load indices.
#include <lsf/lsf.h>char **getIndexList(int *listsize){struct lsInfo *lsInfo = (struct lsInfo *) malloc (sizeof(struct lsInfo));static char *nameList[268];static int first = 1;int i;if (first) {/* only need to do so when called for the first time */lsInfo = ls_info();if (lsInfo == NULL)return (NULL);first = 0;}if (listsize != NULL)*listsize = lsInfo->numIndx;for (i=0; i<lsInfo->numIndx; i++)nameList[i] = lsInfo->resTable[i].name;return (nameList);}
The above code fragment returns a list of load index names currently installed in the LSF cluster. The content of listSize will be modified to the total number of load indices. If ls_info() fails, then the program returns NULL. The data structure returned by ls_info()contains all the load index names before any other resource names. The load index names start with the 11 built-in load indices followed by site external load indices (through ELIM).