Mac: number of bytes transmitted over interface

7

1

On linux, I'm used to typing ifconfig and looking for the line with "RX bytes" and "TX bytes" in it to find out how many bytes have been received and transmitted over a particular interface since boot. The line looks like this:

      RX bytes:106951129 (101.9 MB)  TX bytes:1577761831 (1.4 GB)

I tried running the same command in a terminal on a Mac (OS X, version 10.4.11) but didn't see this data anywhere. How do I get the same information from a Mac?

Edit: This is a test server, meant to simulate a typical out-of-the-box Mac install. So I need to avoid installing any programs if I can. A command-line tool would be ideal.

Douglas Squirrel

Posted 2009-09-01T14:58:50.940

Reputation: 313

Answers

9

netstat -ib

seems to do the trick. Thanks to nik for pointing in the right direction. (Putting the result in a new answer so as not to make future readers dig through comments.)

Douglas Squirrel

Posted 2009-09-01T14:58:50.940

Reputation: 313

From user Girish: Just building on this answer, netstat -ib -I en0 would return the stats for a specific interface.

– fixer1234 – 2018-12-09T00:32:46.240

0

The easiest way I know of seeing bytes in/out over an interface (w/o command line) is with MenuMeters. You can see all that info right on the top bar so it's always visually accessible.

osij2is

Posted 2009-09-01T14:58:50.940

Reputation: 1 937

This mac is a test server so I don't want to install stuff on it if I can avoid it. I need a command-line tool if at all possible. I'll edit the question to say that. – Douglas Squirrel – 2009-09-01T15:41:16.010

Whoops. Sorry, I thought this was for a desktop. :) – osij2is – 2009-09-01T15:54:53.283

0

Try ifconfig -a.
But, I suspect there is a better command for the OSX.
It is discouraged to use the ifconfig command in OSX like its used in Linux.

check networksetup or netstat.

nik

Posted 2009-09-01T14:58:50.940

Reputation: 50 788

ifconfig -a doesn't have the number of bytes (or if it does, I can't find it). networksetup doesn't seem to be available, and netstat (and netstat -a) doesn't seem to have it either. – Douglas Squirrel – 2009-09-01T15:40:26.103

I expected "netstat -i en0" kind of command for the first Ethernet interface. – nik – 2009-09-01T15:49:03.590