I would like to use the terminal to monitor the network traffic on a given interface, with a view to providing alerts when certain cumulative totals have been exceeded.
The script needs to gain statistics from the point in which it is started, and there is no requirement to store values for future reference, or retain values over reboots etc. I would like the output to be human readable, so values in Gb or Mb, not packets or bytes.
The intention is to be able to include this script in an Automator application that will run in the background, and open a dialogue box at set thresholds to alert me to when I nearing a download limit, allowing to choose to disconnect the modem etc.
I do not wish to download any tools or applications, and just wish to use the tools a standard installation provides for the terminal. Getting data out of an application via applescript would be acceptable, but only if that application is also a standard tool, like activity monitor.
netstat -i -I en0 -b
which gives you inbound bytes (along with other stats) for en0 (replace your interface here). You'd obviously then have to use other UNIX tools to parse the output, convert to MB/GB etc. but it might be a start if you've not already done better! I'm suprised someone out there hasn't already created a script of this type as it sounds like a useful thing to have!