Host configuration information

Host configuration information describes the static attributes of individual hosts in the LSF cluster. Examples of such attributes are host type, host model, number of CPUs, total physical memory, and the special resources associated with the host. These attributes are either read from the LSF configuration file, or determined by the host’s LIM on start up.

ls_gethostinfo()

Host configuration information can be obtained by calling ls_gethostinfo():

struct hostInfo *ls_gethostinfo(resreq, numhosts, hostlist, 
                                 listsize, options)

ls_gethostinfo() has these parameters:

char *resreq;       Resource requirements that a host must satisfy 
int *numhosts;      The number of hosts 
char **hostlist;    An array of candidate hosts 
int listsize;       Number of candidate hosts 
int options;        Options, currently only DFT_FROMTYPE 

On success, ls_gethostinfo() returns an array containing a hostInfo structure for each host. On failure, it returns NULL and sets lserrno to indicate the error.

hostInfo structure

The hostInfo structure is defined in lsf.h as

struct hostInfo {
    char  hostName[MAXHOSTNAMELEN];
    char  *hostType;
    char  *hostModel;
    float cpuFactor;
    int   maxCpus;
    int   maxMem;
    int   maxSwap;
    int   maxTmp; 
    int   nDisks;
    int   nRes;
    char  **resources;
    int   nDRes;
    char  **DResources;
    char  *windows;
    int   numIndx;
    float *busyThreshold;
    char  isServer;
    char  licensed;
    int   rexPriority;
    int   licFeaturesNeeded; 
#define LSF_BASE_LIC  0
#define LSF_BATCH_LIC_OBSOLETE 1
#define LSF_JS_SCHEDULER_LIC  2  
#define LSF_JS_LIC  3
#define LSF_CLIENT_LIC  4
#define LSF_MC_LIC  5
#define LSF_ANALYZER_SERVER_LIC  6
#define LSF_MAKE_LIC  7 
#define LSF_PARALLEL_LIC         8 
#define LSF_FLOAT_CLIENT_LIC     9
#define LSF_FTA_LIC              10
#define LSF_AFTER_HOURS_LIC 11
#define LSF_RESOURCE_PREEMPT_LIC 12
#define LSF_BACCT_LIC            13
#define LSF_SCHED_FAIRSHARE_LIC  14
#define LSF_SCHED_RESERVE_LIC    15
#define LSF_SCHED_PREEMPTION_LIC 16
#define LSF_SCHED_PARALLEL_LIC   17
#define LSF_SCHED_ADVRSV_LIC     18
#define LSF_API_CLIENT_LIC       19 
#define CLUSTERWARE_MANAGER_LIC 20
#define LSF_MANAGER_LIC  21
#define LSF_PCC_HPC_LIC          22 /*"platform_hpc" feature*/
#define sCLUSTERWARE_LIC  23 /*"s-Clusterware" OEM for S&C */
#define OTTAWA_MANAGER_LIC       24
#define SYMPHONY_MANAGER_ONLINE_LIC 25
#define SYMPHONY_MANAGER_BATCH_LIC  26
#define SYMPHONY_SCHED_JOB_PRIORITY_LIC 27
#define LSF_DUALCORE_X86_LIC     28
#define LSF_TSCHED_LIC           29
#define LSF_NUM_LIC_TYPE         30
#define LSF_NO_NEED_LIC          32
    int licClass;                /*license class needed */
    int cores;                   /* number of cores per physical CPU */
#ifndef INET6_ADDRSTRLEN
# define INET6_ADDRSTRLEN 46
#endif
    char hostAddr[INET6_ADDRSTRLEN]; /* IP address of this host */
    int pprocs;                   /* 82185 - Num physical processors. */
    /* cores_per_proc and cores are both needed for backwards compatibility.
    * cores is used for licencing enforcement and cores_per_proc is needed
    * for ncpus computation. */
    int cores_per_proc;           /* 82185 - Num cores per processor. */
   int threads_per_core;         /* 82185 - Num threads per core. */
};
Tip:

On Solaris, when referencing MAXHOSTNAMELEN, netdb.h must be included before lsf.h or lsbatch.h.

NULL and 0 were supplied for the hostlist and listsize parameters of the ls_gethostinfo() call. This causes all LSF hosts meeting resreq to be returned. If a host list parameter is supplied with this call, the selection of hosts will be limited to those belonging to the list.

If resreq is NULL, then the default resource requirements will be used.

The values of maxMem and maxCpus (along with maxSwap, maxTmp, and nDisks) are determined when LIM starts on a host. If the host is unavailable, the master LIM supplies a negative value.

Example

The following example shows how to use ls_gethostinfo() in a C program. It displays the name, host type, total memory, number of CPUs and special resources for each host that has more than 50MB of total memory.

#include <netdb.h>    /* Required for Solaris to reference 
                      MAXHOSTNAMELEN */ 
#include <lsf/lsf.h> 
#include <stdio.h> 
 
main() 
{ 
    struct hostInfo *hostinfo; 
    char   *resreq; 
    int    numhosts = 0; 
    int    options = 0; 
    int    i, j;
/* only hosts with maximum memory larger than 50 Mbytes are of interest */
   resreq="maxmem>50";
/* get information on interested hosts */
   hostinfo = ls_gethostinfo(resreq, &numhosts, NULL, 0, options); 
    if (hostinfo == NULL) { 
        ls_perror("ls_gethostinfo"); 
        exit(‑1); 
    } 
/* print out the host names, host types, maximum memory, number of CPUs and number of resources */
    printf("There are %d hosts with more than 50MB total memory          \n\n", numhosts); 
    printf("%‑11.11s %8.8s %6.6s %6.6s %9.9s\n", 
           "HOST_NAME", "type", "maxMem", "ncpus", "RESOURCES"); 
 
    for (i = 0; i < numhosts; i++) { 
        printf("%‑11.11s %8.8s", hostinfo[i].hostName, 
                hostinfo[i].hostType); 
 
        if (hostinfo[i].maxMem > 0) 
            printf("%6dM ", hostinfo[i].maxMem); 
        else                       /* maxMem info not available for this host*/ 
            printf("%6.6s ", "‑"); 
 
        if (hostinfo[i].maxCpus > 0) 
            printf("%6d ", hostinfo[i].maxCpus); 
        else              /* ncpus is not known for this host*/ 
            printf("%6.6s", "‑"); 
 
        for (j = 0; j < hostinfo[i].nRes; j++) 
            printf(" %s", hostinfo[i].resources[j]); 
 
        printf("\n"); 
    } 
    exit(0); 
}

In the above example, resreq defines the resource requirements used to select the hosts. The variables you can use for resource requirements must be the resource names returned from ls_info(). You can run the lsinfo command to obtain a list of valid resource names in your LSF cluster.

The above example program produces output similar to the following:

% a.out 
There are 4 hosts with more than 50MB total memory 
 
HOST_NAME   type     maxMem ncpus RESOURCES 
hostA      HPPA10    128M    1    hppa hpux cs  
hostB      ALPHA      58M    2    alpha cs 
hostD      ALPHA      72M    4    alpha fddi 
hostC      SUNSOL     54M    1    solaris fddi 

To get specific host information use:

  • char *ls_gethosttype(hostname)

  • Returns the type of a specific host

  • char *ls_gethostmodel(hostname)

  • Returns the model of a specific host

  • float *ls_gethostfactor(hostname)

  • Returns the CPU factor of the specified host