You can also use vnstat with vnstati to generate nice graphs.<p>I use it something like this with cron.<p>Bash - <a href="https://github.com/tuxy/bash/blob/master/vnstat.sh" rel="nofollow">https://github.com/tuxy/bash/blob/master/vnstat.sh</a><p>HTML - <a href="https://github.com/tuxy/static/blob/master/vnstat.html" rel="nofollow">https://github.com/tuxy/static/blob/master/vnstat.html</a>
I've used vnstat for traffic monitoring on Linux/BSD routers for years, simple and does the job.
The on-disk format is <i>not</i> machine-independent though, I had to start my records over when OpenBSD went to 64-bit time_t.
Been looking for a tool like iptraf or nethogs for OSX. nettop is ok.
My favorite thus far are these two dtrace scripts for tracing network connections:<p>soconnect.d: <a href="http://dtracebook.com/index.php/Network_Lower_Level_Protocols:soconnect.d#Mac_OS_X" rel="nofollow">http://dtracebook.com/index.php/Network_Lower_Level_Protocol...</a><p>soaccept.d: <a href="http://dtracebook.com/index.php/Network_Lower_Level_Protocols:soaccept.d#Mac_OS_X" rel="nofollow">http://dtracebook.com/index.php/Network_Lower_Level_Protocol...</a><p>If you're on OSX and want to play around with dtrace, there are a bunch of really cool built-in scripts:<p><pre><code> man -k dtrace</code></pre>