Using libprefstat on AIX 5.3 dumps core - Aix

This is a discussion on Using libprefstat on AIX 5.3 dumps core - Aix ; Hi, I juste compiled a sample program, used to monitor network throughpout with function from libperfstat.a. The problem is that the program dumps a core when it tries to execute this call: ret = perfstat_netinterface((perfstat_id_t *)FIRST_NETINTERFACE, stat, sizeof(perfstat_netinterface_t),tot); I tried ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Using libprefstat on AIX 5.3 dumps core

  1. Using libprefstat on AIX 5.3 dumps core

    Hi,

    I juste compiled a sample program, used to monitor network throughpout
    with function from libperfstat.a.

    The problem is that the program dumps a core when it tries to execute
    this call:
    ret = perfstat_netinterface((perfstat_id_t *)FIRST_NETINTERFACE, stat,
    sizeof(perfstat_netinterface_t),tot);
    I tried on an AIX 5.3, ML04.

    The program and source are from:
    http://www-941.ibm.com/collaboration.../WikiPtype/ryo

    If I download the "net" binary, it works like a charm.

    I'm wondering... can someone with AIX 5.3 ML03 send me the
    /usr/lib/libperfstat.a ? I'm pretty sure that it'd do the trick ;-)

    Cheers,
    Valoche

    HERE IS THE CODE: compile with cc net.c -o net -lperfstat
    =================
    #include
    #include
    #include
    #include
    #include

    #ifndef FIRST_NETINTERFACE
    #define FIRST_NETINTERFACE ""
    #endif
    int main(int argc, char* argv[]) {
    int i, ret, tot;
    perfstat_netinterface_t *stat;

    tot = perfstat_netinterface(NULL, NULL,
    sizeof(perfstat_netinterface_t), 0);
    stat = malloc(sizeof(perfstat_netinterface_t)*tot);

    ret = perfstat_netinterface((perfstat_id_t
    *)FIRST_NETINTERFACE, stat, sizeof(perfstat_netinterface_t),tot);
    while(1) {
    ret = perfstat_netinterface((perfstat_id_t *)"", stat,
    sizeof(perfstat_netinterface_t),tot);
    if(ret <= 0) {
    printf("tot=%d ret=%d errno=%d\n",tot,ret,errno);
    perror("x");
    exit(42);
    }

    for (i = 0; i < ret; i++) {
    printf("\nStatistics for networks : %s\n",
    stat[i].name);
    printf("----------------------\n");
    printf("mtu : %llu\n", stat[i].mtu);
    printf("description : %s\n",
    stat[i].description);
    printf("ipackets : %d\n", stat[i].ipackets);
    printf("opackets : %llu\n", stat[i].opackets);
    printf("ibytes : %d\n", stat[i].ibytes);
    printf("obytes : %llu\n", stat[i].obytes);
    printf("ierrors : %d\n", stat[i].ierrors);
    printf("oerrors : %llu\n", stat[i].oerrors);
    printf("collisions : %d\n", stat[i].collisions);
    #if (_AIX52 | _AIX53)
    printf("bitrate bit/sec: %llu\n", stat[i].bitrate);
    printf("bitrate mbits/sec: %llu\n",
    stat[i].bitrate/1024/1024);
    #endif
    }
    sleep(1);
    }
    }


  2. Re: Using libprefstat on AIX 5.3 dumps core

    valery.fouques@free.fr schrieb:
    > Hi,
    >
    > I juste compiled a sample program, used to monitor network throughpout
    > with function from libperfstat.a.
    >
    > The problem is that the program dumps a core when it tries to execute
    > this call:
    > ret = perfstat_netinterface((perfstat_id_t *)FIRST_NETINTERFACE, stat,
    > sizeof(perfstat_netinterface_t),tot);
    > I tried on an AIX 5.3, ML04.


    which compiler do you use? I learned some time ago that these samples
    run well when compiled with IBM's vacc and dump core when compiled with gcc.

  3. Re: Using libprefstat on AIX 5.3 dumps core


    Joachim Gann a écrit :

    > which compiler do you use? I learned some time ago that these samples
    > run well when compiled with IBM's vacc and dump core when compiled with gcc.


    I use gcc ;-)
    I'm gonna try and have IBM cc installed on my box, and give it a try.

    Thanks !


+ Reply to Thread