Record daily internet bandwidth usage

bandwidthinternet

I am using internet connection with data cap. I want to record my daily internet usage in a file, is there any tool for this or perhaps you can suggest a script that would run as daemon?

(I am not pro in bash scripting or with linux administrating software so a simple script will be recommended)

Best Answer

I use vnstat, which keeps track of daily stats for the last 30 days, and is available in the Ubuntu/Debian (and probably many more) repos.

Just install it and use it like vnstat -i wlan0 -h:

 wlan0                                                                    14:47 
  ^                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                           r                 
  |                                                     r     r  r     r        
  |                                                     rt r  rt rt    r        
 -+---------------------------------------------------------------------------> 
  |  15 16 17 18 19 20 21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14    

 h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB)      h  rx (KiB)   tx (KiB) 
15          0          0    23          0          0    07          0          0
16          0          0    00          0          0    08     19,287      7,859
17          0          0    01          0          0    09      6,550      3,231
18          0          0    02          0          0    10     65,500      9,216
19          0          0    03          0          0    11     17,491      7,502
20          0          0    04          0          0    12      5,158      2,503
21          0          0    05          0          0    13     15,034      3,493
22          0          0    06          0          0    14      4,284      2,503
Related Question