Search code examples
loadlsf

can lsload print in standard integer format?


I am using lsload -I io in LSF to measure IO use on our nodes and if the io values gets above 9999, it turns to scientific format like 1e+04 or 4e+04. Is there a way to get the actual numbers in integer (rather than scientific) format?


Solution

  • I can't seem to find a way to do it through the existing lsload command, but you can do it by using the API to write a simple command to fetch it for you.

    Here's some (very ad hoc) sample code to return the 'io' load on all hosts as a float, you can probably modify it to do fancy stuff like just give you the hosts you want etc.

    ls_ioload.c:

    #include <stdio.h>
    #include <stdlib.h>
    #include <lsf/lsf.h>
    
    
    int main(int argc, char *argv[]) {
        struct hostLoad* hL;
        int numhosts = 0;
        char* hostnames[256];
        char* indices[] = { "io" , NULL };
        char** nlp = indices;
        int i;
    
        hL = ls_loadinfo(NULL,&numhosts,OK_ONLY|IGNORE_RES,NULL,hostnames,0,&nlp);
        if( !hL ){
            ls_perror("ls_ioload");
            exit(-10);
        }
    
        if( nlp[0] ){
            printf("HOST\t%s\n",nlp[0]);
            for(i = 0; i < numhosts; i++){
                printf("%s\t%f\n",hL[i].hostName,hL[i].li[0]);
            }
        }
        exit(0);
    }
    

    You can compile with something like:

    gcc -o ls_ioload -I$LSF_ENVDIR/../9.1/include ls_ioload.c $LSF_ENVDIR/../9.1/linux2.6-glibc2.3-x86_64/lib/liblsf.a
    

    Sample output on my little single host cluster:

    [~]$ lsload -I io
    HOST_NAME       status    io
    hostA               ok  1e+4
    
    [~]$ ./ls_ioload
    HOST    io
    hostA   12074.595703