How to check Internet usage

I have a SIM slot in my ThinkPad X1 Carbon, although I haven't yet configured it to access the Internet, although I know I can do so under Windows.

Is there some command I can issue to monitor how much traffic goes through a particular interface?
 
with conky you can show data per interface eg,
Code:
${color grey}UpSpeed  :$color ${upspeed tun0}/${upspeed re0}  
${color grey}DownSpeed:$color ${downspeed tun0}/${downspeed re0}
${color grey}TotalUp  :$color ${totalup tun0}/${totalup re0}
${color grey}TotalDown:$color ${totaldown tun0}/${totaldown re0}
 
Generally you configure a firewall and let the packet filter do the counting of volume (as opposed to # of packets).

Example: # ipfw -t show output per rule:
rulenum packets bytes timestamp ruletext

So using rules:
Code:
# ipfw add 100 count all from any to any in recv $interface
# ipfw add 200 count all from any to any out xmit $interface

Many if not most ISPs account for / charge traffic as the total of received and sent by you.

At the end of desired period (e.g. hourly, daily, weekly, monthly ...) record the counts then
# ipfw zero 100 200
 
Yeah, you want something that'll count the totals too, the interface counters get reset when then interface goes down. But with 4G/Edge/5G you often have a data limit on a monthly basis, so you want to keep track of the counters during that entire period to add everything up and warn you when you're close to the limit for that month.
 
Yeah, you want something that'll count the totals too, the interface counters get reset when then interface goes down. But with 4G/Edge/5G you often have a data limit on a monthly basis, so you want to keep track of the counters during that entire period to add everything up and warn you when you're close to the limit for that month.
I'd also like to know how much I'm using on average each month so that I can choose the appropriate packet.
 
Yeah, you want something that'll count the totals too, the interface counters get reset when then interface goes down.

Whereas ipfw(8) counts are only reset on reboot (which can be handled by the service script) or deliberately as above, even if the interface goes down or returns with the link.

I can't speak for pfctl(8) at all, but suppose similar functionality would exist.

The runtime to process a few firewall rules, especially with even 5G data rates, is entirely negligible.

But with 4G/Edge/5G you often have a data limit on a monthly basis, so you want to keep track of the counters during that entire period to add everything up and warn you when you're close to the limit for that month.

Indeed. That's going to require some scripting, if there isn't already something to do that?

I'd also like to know how much I'm using on average each month so that I can choose the appropriate packet.

You're good at scripting, eh?

You could get fancy with an sqlite database, but parsing stats out to simple text files using standard sh(1) arithmetic should suffice.
 
Back
Top