General cluster configuration information

In the previous chapter, a very simple application was introduced that prints the name of the LSF cluster. This section extends that example by printing the current master host name and the defined resource names in the cluster. It uses the following additional LSLIB function calls:

struct lsInfo *ls_info(void) 
char *ls_getclustername(void) 
char *ls_getmastername(void)

All of these functions return NULL on failure and set lserrno to indicate the error.

lsinfo structure

The function ls_info() returns a pointer to the lsinfo data structure

(defined in <lsf/lsf.h>):

struct lsInfo { 
   int   nRes;                 Number of resources in the system 
   struct resItem *resTable;    A resItem for each resource in the system 
   int   nTypes;               Number of host types 
   char  hostTypes[MAXTYPES][MAXLSFNAMELEN];   Host types 
   int   nModels;              Number of host models 
   char  hostModels[MAXMODELS][AXLSFNAMELEN];  Host models 
   char  hostArchs[MAXMODELS][MAXLSFNAMELEN];  Architecture name 
   int   modelRefs[MAXMODELS]; Number of hosts of this architecture 
   float cpuFactor[MAXMODELS];  CPU factors of each host model 
   int   numIndx;              Total number of load indices in resItem 
   int   numUsrIndix;          Number of user-defined load indices 
};

resItem structure

Within struct lsinfo, the resItem data structure describes the valid resources defined in the LSF cluster:

struct resItem { 
   char name[MAXLSFNAMELEN];  The name of the resource 
   char des[MAXRESDESLEN];    The description of the resorce 
   enum valueType valueType; Type of value: BOOLEAN, NUMERIC,                                STRING, EXTERNAL 
   enum orderType orderType;  Order: INCR, DECR, NA 
   int  flags;              Resource attribute flags  
#define RESF_BUILTIN 0x01   Built-in vs configured resource 
#define RESF_DYNAMIC 0x02   Dynamic vs static value 
#define RESF_GLOBAL 0x04    Resource defined in all clusters 
#define RESF_SHARED 0x08    Shared resource for some hosts 
#define RESF_LIC 0x10       License static value 
#define RESF_EXTERNAL 0x20  External resource defined 
#define RESF_RELEASE 0x40   Resource can be released when job is 
                            suspended 
   int interval;            The update interval for a load index, in seconds 
};

The constants MAXTYPES, MAXMODELS, and MAXLSFNAMELEN are defined in <lsf/lsf.h>. MAXLSFNAMELEN is the maximum length of a name in LSF.

A host type in LSF refers to a class of hosts that are considered to be compatible from an application point of view. This is entirely configurable, although normally hosts with the same architecture (binary compatible hosts) should be configured to have the same host type.

A host model in LSF refers to a class of hosts with the same CPU performance. The CPU factor of a host model should be configured to reflect the CPU speed of the model relative to other host models in the LSF cluster.

ls_getmastername() returns a string containing the name of the current master host.

ls_getclustername() returns a string containing the name of the local load sharing cluster defined in the configuration files.

The returned data structure of every LSLIB function is dynamically allocated inside LSLIB. This storage space is automatically freed by LSLIB and re-allocated next time the same LSLIB function is called. An application should never attempt to free the storage returned by LSLIB. If you need to keep this information across calls, make your own copy of the data structure. This applies to all LSLIB function calls.

Example

The following program displays LSF cluster information using the above LSLIB function calls.

#include <stdio.h> 
#include <lsf/lsf.h> 
 
main() 
{ 
    struct lsInfo *lsInfo; 
    char *cluster, *master; 
    int i;
/* get the name of the local load sharing cluster */
    cluster = ls_getclustername(); 
    if (cluster == NULL) { 
        ls_perror("ls_getclustername"); 
        exit(‑1); 
    } 
    printf("My cluster name is <%s>\n", cluster);
/* get the name of the current master host */
    master = ls_getmastername(); 
    if (master == NULL) { 
        ls_perror("ls_getmastername"); 
        exit(‑1); 
    } 
    printf("Master host is <%s>\n", master);
/* get the load sharing configuration information */
    lsInfo = ls_info(); 
    if (lsInfo == NULL) { 
        ls_perror("ls_info"); 
        exit(‑1); 
    } 
    printf("\n%‑15.15s %s\n", "RESOURCE_NAME", "DESCRIPTION"); 
    for (i=0; i<lsInfo‑>nRes; i++) 
        printf("%‑15.15s %s\n",  
            lsInfo‑>resTable[i].name, lsInfo‑>resTable[i].des); 
 
    exit(0); 
}

The above program will produce output similar to the following:

% a.out 
My cluster name is <test_cluster> 
Master host is <hostA> 
 
RESOURCE_NAME      DESCRIPTION 
r15s               15‑second CPU run queue length 
r1m                1‑minute CPU run queue length (alias: cpu) 
r15m               15‑minute CPU run queue length 
ut                 1‑minute CPU utilization (0.0 to 1.0) 
pg                 Paging rate (pages/second) 
io                 Disk IO rate (Kbytes/second) 
ls                 Number of login sessions (alias: login) 
it                 Idle time (minutes) (alias: idle) 
tmp                Disk space in /tmp (Mbytes) 
swp                Available swap space (Mbytes) (alias: swap) 
mem                Available memory (Mbytes) 
ncpus              Number of CPUs 
ndisks             Number of local disks 
maxmem             Maximum memory (Mbytes) 
maxswp             Maximum swap space (Mbytes) 
maxtmp             Maximum /tmp space (Mbytes) 
cpuf               CPU factor 
rexpri             Remote execution priority 
server             LSF server host 
LSF_Base           Base product 
lsf_base           Base product 
LSF_Manager        Standard product 
lsf_manager        Standard product 
LSF_JobSchedule    JobScheduler product 
lsf_js             JobScheduler product 
LSF_Make           Make product 
lsf_make           Make product 
LSF_Parallel       Parallel product 
lsf_parallel       Parallel product 
LSF_Analyzer       Analyzer product 
lsf_analyzer       Analyzer product 
mips               MIPS architecture 
dec                DECStation system 
sparc              SUN SPARC 
bsd                BSD unix 
sysv               System V UNIX 
hpux               HP-UX UNIX 
aix                AIX UNIX 
irix               IRIX UNIX 
ultrix             Ultrix UNIX 
solaris            SUN SOLARIS 
sun41              SunOS4.1 
convex             ConvexOS 
osf1               OSF/1 
fs                 File server 
cs                 Compute server 
frame              Hosts with FrameMaker license 
bigmem             Hosts with very big memory 
diskless           Diskless hosts 
alpha              DEC alpha 
linux              LINUX UNIX 
type               Host type 
model              Host model 
status             Host status 
hname              Host name