1

wondering whether there is any method to monitor wifi and ethernet internet data consumption (up and down separately) and log it. I am trying to calculate daily, weekly and monthly data consumption for Wifi and Ethernet. If possible, per session too.

I see that the System Monitor already display the Sent and Received data. Wondering if any method exists to get data like that and log it. A shell script or Python. I know a bit of Python, thanks.

PS: Using 22.04

0

1 Answer 1

1

vnStat is exactly what you want, as it appears. Luckily, it's already in the official universe repositories.

vnStat is a console-based network traffic monitor. It keeps a log of 5 minute interval, hourly, daily, monthly and yearly network traffic for the selected interface(s).

You can simply install it with:

sudo apt install vnstat

... then, statistics will be available later (give it some time) and you can view them with e.g. :

$ vnstat -m

 wlp2s0  /  monthly

        month        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2023-01     13.81 GiB |    5.85 GiB |   19.66 GiB |   63.06 kbit/s
       2023-02     10.08 GiB |    1.40 GiB |   11.48 GiB |   40.76 kbit/s
       2023-03     22.25 GiB |    8.18 GiB |   30.43 GiB |   97.58 kbit/s
       2023-04     16.21 GiB |    1.64 GiB |   17.84 GiB |   59.13 kbit/s
       2023-05      8.03 GiB |    0.98 GiB |    9.02 GiB |   28.91 kbit/s
       2023-06     18.69 GiB |    1.02 GiB |   19.71 GiB |   65.30 kbit/s
       2023-07    122.22 GiB |    5.93 GiB |  128.16 GiB |  411.01 kbit/s
       2023-08     14.19 GiB |    1.36 GiB |   15.56 GiB |   49.90 kbit/s
       2023-09     22.69 GiB |    2.01 GiB |   24.70 GiB |   81.84 kbit/s
       2023-10      2.94 GiB |  209.90 MiB |    3.15 GiB |   84.25 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated     24.56 GiB |    1.71 GiB |   26.27 GiB |

for monthly statistics ... or change -m to -h, -d or -y for hourly, daily or yearly statistics respectively and a lot of features as well.

2
  • Thanks. I did see, wondering whether I can fetch data from it too. It works no doubt, only curious whether we can use it to feed our own logs or database.
    – user227495
    Oct 4 at 15:33
  • 1
    @user227495 Of course we can ... Have a look at vnstat --xml or vnstat --json for example.
    – Raffa
    Oct 4 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .