Skip to content

vnstat

vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s).

  • It uses the network interface statistics provided by the kernel as information source.
  • It keeps a log of 5 minute interval, hourly, daily, monthly and yearly network traffic for the selected interface(s). However, it isn't a packet sniffer.
  • The traffic information is read from the proc(5) or sys filesystems depending on availability resulting in light use of system resources regardless of network traffic rate. That way vnStat can be used even without root permissions on most systems.

Installation

[root@localhost ~]# yum whatprovides vnstat
Last metadata expiration check: 4:17:32 ago on Saturday 11 April 2020 11:09:20 AM IST.
vnstat-2.3-2.fc31.x86_64 : Console-based network traffic monitor
Repo        : fedora
Matched from:
Provide    : vnstat = 2.3-2.fc31

[root@localhost ~]# yum install vnstat
Last metadata expiration check: 4:17:47 ago on Saturday 11 April 2020 11:09:20 AM IST.
Dependencies resolved.
=================================================================================================================
 Package                  Architecture             Version                        Repository                Size
=================================================================================================================
Installing:
 vnstat                   x86_64                   2.3-2.fc31                     fedora                   149 k

Transaction Summary
=================================================================================================================
Install  1 Package

Total download size: 149 k
Installed size: 437 k
Is this ok [y/N]: y
Downloading Packages:
vnstat-2.3-2.fc31.x86_64.rpm                                                      73 kB/s | 149 kB     00:02    
-----------------------------------------------------------------------------------------------------------------
Total                                                                             17 kB/s | 149 kB     00:08     
warning: /var/cache/dnf/fedora-3589ee8a7ee1691d/packages/vnstat-2.3-2.fc31.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 3c3359c4: NOKEY
Fedora 31 - x86_64                                                               1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x3C3359C4:
 Userid     : "Fedora (31) <[email protected]>"
 Fingerprint: 7D22 D586 7F2A 4236 474B F7B8 50CB 390B 3C33 59C4
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-31-x86_64
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                         1/1 
  Running scriptlet: vnstat-2.3-2.fc31.x86_64                                                                1/1 
  Installing       : vnstat-2.3-2.fc31.x86_64                                                                1/1 
  Running scriptlet: vnstat-2.3-2.fc31.x86_64                                                                1/1 
  Verifying        : vnstat-2.3-2.fc31.x86_64                                                                1/1 

Installed:
  vnstat-2.3-2.fc31.x86_64                                                                                       

Complete!
[root@localhost ~]# 

Start Service

[root@localhost ~]# systemctl start  vnstat
[root@localhost ~]# systemctl status  vnstat
● vnstat.service - vnStat network traffic monitor
   Loaded: loaded (/usr/lib/systemd/system/vnstat.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-04-11 15:34:52 IST; 4s ago
     Docs: man:vnstatd(1)
           man:vnstat(1)
           man:vnstat.conf(5)
 Main PID: 103012 (vnstatd)
    Tasks: 1 (limit: 8804)
   Memory: 1.7M
      CPU: 44ms
   CGroup: /system.slice/vnstat.service
           └─103012 /usr/sbin/vnstatd -n
[root@localhost ~]#

Fetch stats

[root@localhost ~]# vnstat

                      rx      /      tx      /     total    /   estimated
 enp2s0: Not enough data available yet.
 virbr0: Not enough data available yet.
 virbr0-nic: Not enough data available yet.
 wlp4s0:
       2020-04    899.54 KiB  /  578.02 KiB  /    1.44 MiB  /    2.47 MiB
         today    899.54 KiB  /  578.02 KiB  /    1.44 MiB  /    2.20 MiB

[root@localhost ~]# 

For more details

man vnstat
Back to top