Skip to content

How to monitor your bandwith on a single client with vnstat

Sometimes you wonder how much traffic you just used to stream a music video or just checking out some repositories. In some cases it is good to know how much you just used (i.e. some contracts with limited bandwidth promisises – like mobilephones). vnstat is a little piece of software which periodically captures your foodprints on your local client. It listens to a (or more) specific network devices.

To install this nead software just type:

# su - 
# pacman -Sy vnstat

You need to adjust the interface you want to be monitored in the vnstat.conf.
To see which interfaces are available type:

# ip a s

This give for example the following output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether bc:5f:f4:37:dd:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.225/24 brd 192.168.1.255 scope global enp4s0
       valid_lft forever preferred_lft forever
    inet6 fe80::be5f:f4ff:fe37:dd56/64 scope link 
       valid_lft forever preferred_lft forever

So… enp4s0 is my interface – now I just need to edit the config-file and add my card:

# nano /etc/vnstat.conf
Interface "enp4s0"

Now we need to start vnstat for one time manually to create the database for the data:

# vnstat -u -i enp4s0

Now just type into the console for persistent use:

# systemctl start vnstat
# systemctl enable vnstat

with

# vnstat -u

you update your stats – and

# vnstat

outputs your current stats.

Database updated: Wed Jan 15 22:45:46 2014

   enp4s0 since 01/15/14

          rx:  8.94 GiB      tx:  179.59 MiB      total:  9.12 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       Jan          8.94 GiB |  179.59 MiB |    9.12 GiB |   59.21 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated     18.54 GiB |     371 MiB |   18.90 GiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
         today      8.94 GiB |  179.59 MiB |    9.12 GiB |  933.14 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      9.43 GiB |     188 MiB |    9.61 GiB |
Links:
[1] vnstat-Homepage: http://humdi.net/vnstat

Post a Comment

You must be logged in to post a comment.