AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
Expand all | Collapse all

Different network interface statistics (entstat vs perfstat API)

  • 1.  Different network interface statistics (entstat vs perfstat API)

    Posted Thu July 05, 2012 08:45 AM

    Originally posted by: dimir


    I need to create a C program to get network interface statistics (e. g. in/out packets/bytes/errors). I used examples of using libperfstat here:

    http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.prftools/doc/prftools/prftools07.htm

    It works well but for some reason the results I get totally differ from what entstat command shows. And it happens on 2 different machines (5.3 and 6.1). Does anybody know why is the difference and should I make any adjustments to my program in order to get proper results?

    Below are details on the subject.

    ###################
    1. My program code #
    ###################

    $ cat perfstat-net.c
    #include <stdio.h>
    #include <stdlib.h>
    #include <libperfstat.h>
    #include <string.h>

    int main(int argc, char *argv[])
    {
    perfstat_netinterface_t ps_if;
    perfstat_id_t ps_id;

    if (argc != 2) {
    fprintf(stderr, "usage: %s <device>\n", argv[0]);
    exit(EXIT_FAILURE);
    }

    strcpy(ps_id.name, argv[1]);

    if (perfstat_netinterface(&ps_id, &ps_if, sizeof(perfstat_netinterface_t), 1) != 1) {
    fprintf(stderr, "perfstat_netinterface() failed\n");
    exit(EXIT_FAILURE);
    }

    printf("Statistics for interface : %s\n", ps_if.name);
    printf("------------------------\n");
    printf("\ninput statistics:\n");
    printf("number of packets : %llu\n", ps_if.ipackets);
    printf("number of bytes : %llu\n", ps_if.ibytes);
    printf("number of errors : %llu\n", ps_if.ierrors);
    printf("\noutput statistics:\n");
    printf("number of packets : %llu\n", ps_if.opackets);
    printf("number of bytes : %llu\n", ps_if.obytes);
    printf("number of errors : %llu\n", ps_if.oerrors);

    exit(EXIT_SUCCESS);
    }

    #####################
    1. My program output #
    #####################

    $ gcc -o perfstat-net perfstat-net.c -lperfstat -Wall && ./perfstat-net en1
    Statistics for interface : en1


    input statistics:
    number of packets : 508180206 <--- in packets
    number of bytes : 3914575317 <--- in bytes
    number of errors : 0 <--- in errors

    output statistics:
    number of packets : 899241 <--- out packets
    number of bytes : 66302139 <--- out bytes
    number of errors : 0 <--- out errors

    ##################
    1. entstat output #
    ##################

    $ entstat en1

    ETHERNET STATISTICS (en1) :
    Device Type: Host Ethernet Adapter (l-hea)
    Hardware Address: 00:1a:64:f0:3a:31
    Elapsed Time: 25 days 22 hours 24 minutes 24 seconds

    Transmit Statistics: Receive Statistics:


    Packets: 183463 Packets: 49625506 <--- out/in packets
    Bytes: 13869163 Bytes: 4238405514 <--- out/in bytes
    Interrupts: 0 Interrupts: 49147441
    Transmit Errors: 1498 Receive Errors: 0 <--- out/in errors
    http://...

    ##############
    1. OS version #
    ##############

    $ oslevel -s
    6100-01-01-0823
    #AIX-Forum


  • 2.  Re: Different network interface statistics (entstat vs perfstat API)

    Posted Fri July 06, 2012 11:04 AM

    Originally posted by: SystemAdmin


    entstat gives statistics for ethernet device driver and device. For comparison with perfstat network interface statistics, you should use netstat with option -i or -I <interface>.
    #AIX-Forum


  • 3.  Re: Different network interface statistics (entstat vs perfstat API)

    Posted Mon July 09, 2012 05:07 AM

    Originally posted by: dimir


    Thank you for the answer, indeed with

    netstat -D -I en1

    I get the same results as perftat API returns. So, you mean, entstat gives ethernet device driver statistics (software level) while perfstat gives statistics of the device itself (hardware level)?
    #AIX-Forum