Neville Hillyer

Q: Why does netstat not output cumulative values?

I would be grateful if somebody could explain why the following command does not output cumulative values as implied by the man page:

 

netstat -I en0 -w 5 -b

Mac OS X (10.5.8), on 733 MHz G4+, G3s, Ubuntu on R630

Posted on Dec 15, 2015 2:37 PM

Close

Q: Why does netstat not output cumulative values?

  • All replies
  • Helpful answers

  • by Hiroto,Solvedanswer

    Hiroto Hiroto Dec 16, 2015 6:34 AM in response to Neville Hillyer
    Level 5 (7,286 points)
    Dec 16, 2015 6:34 AM in response to Neville Hillyer

    Hello

     

    Quote from netstat(1) man page -

     

    If a wait interval is specified, the protocol information over the last interval seconds will be displayed.

     

     

    And I get something like this:

     

     

    $ netstat -I en0 -w5 -b
                input          (en0)           output
       packets  errs      bytes    packets  errs      bytes colls
             3     0        210          1     0         90     0
            25     0       1927         38     0       2503     0
             5     0        379          7     0        451     0
             0     0          0          0     0          0     0
    ^C
    $ 
    

     

     

     

    Tested under OS X 10.6.8.

     

    Regards,

    H

  • by Neville Hillyer,

    Neville Hillyer Neville Hillyer Dec 16, 2015 7:08 AM in response to Hiroto
    Level 4 (1,877 points)
    Mac OS X
    Dec 16, 2015 7:08 AM in response to Hiroto


    You are correct. I took too much notice of:

     

    "The interface display provides a table of cumulative statistics regarding packets transferred, errors, and collisions."

     

    I now see that I can get what I want by putting netstat -bI en0 inside my own loop and extracting the cumulative byte count.

     

    Many thanks for your help.