https://humdi.net/vnstat/
# CentOS 7 安装
yum install vnstat
# 开机自动启动
systemctl enable vnstat
# 修改默认网卡:Interface "" 为 Interface "eth0"
# 注意查看网上名
vim /etc/vnstat.conf
Interface "eth0"
# 重启主机
reboot
[root@ip-172 ~]# vnstat -5
eth0 / 5 minute
time rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
2020-09-25
09:40 2.80 KiB | 4.24 KiB | 7.04 KiB | 192 bit/s
09:45 18.49 KiB | 21.51 KiB | 40.00 KiB | 1.26 kbit/s
------------------------+-------------+-------------+---------------
[root@ip-172 ~]# vnstati -i eth0 --months --output /usr/share/nginx/html/month.png
[root@ip-172 ~]# vnstati -i eth0 --days --output /usr/share/nginx/html/days.png
源码编译安装
yum install gcc make sqlite-devel
wget https://humdi.net/vnstat/vnstat-2.6.tar.gz
tar -xvf vnstat-2.6.tar.gz
cd vnstat-2.6
./configure --prefix=/usr --sysconfdir=/etc && make && make install
cp -v examples/systemd/vnstat.service /etc/systemd/system/
systemctl enable vnstat
systemctl start vnstat