Foreword
简单统计一下网口流量
vnstat
https://humdi.net/vnstat/
$ vnstat --help
vnStat 2.10 by Teemu Toivola
-5, --fiveminutes [limit] show 5 minutes
-h, --hours [limit] show hours
-hg, --hoursgraph show hours graph
-d, --days [limit] show days
-m, --months [limit] show months
-y, --years [limit] show years
-t, --top [limit] show top days
-b, --begin set list begin date
-e, --end set list end date
--oneline [mode] show simple parsable format
--json [mode] [limit] show database in json format
--xml [mode] [limit] show database in xml format
--alert
alert if limit is exceeded
-tr, --traffic [time] calculate traffic
-l, --live [mode] show transfer rate in real time
-i, --iface select interface (default: eth0)
Use "--longhelp" or "man vnstat" for complete list of options.
安装vnstat
yum install vnstat -y
apt-get install vnstat -y
一般网口都是eth0,创建网口统计
vnstat --create -i eth0
不排除某些linux是特殊名称
vnstat --create -i enp0s3
vnstat --create -i ens3
设置开机启动并重启
systemctl enable vnstat
systemctl restart vnstat
使用
月统计,默认显示的是eth0的网卡流量,如果网卡名不同,需要指定
vnstat -m
vnstat -m -i enp0s3
vnstat -m -i ens3
日统计
vnstat -d
vnstat -d -i enp0s3
$ vnstat
Database updated: 2018-10-21 20:11:20
eth0 since 2010-12-16
rx: 144.21 GB tx: 380.53 GB total: 524.74 GB
monthly
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
2018-09 1.82 GB | 7.99 GB | 9.81 GB | 32.52 kbit/s
2018-10 1.71 GB | 7.64 GB | 9.35 GB | 44.80 kbit/s
------------------------+-------------+-------------+---------------
estimated 2.56 GB | 11.41 GB | 13.97 GB |
daily
rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
yesterday 72.69 MB | 333.94 MB | 406.63 MB | 39.48 kbit/s
today 67.21 MB | 279.75 MB | 346.96 MB | 40.05 kbit/s
------------------------+-------------+-------------+---------------
estimated 79.92 MB | 332.65 MB | 412.57 MB |
No package xxx available
可能遇到没有安装eple
No package epel-release available
下载安装
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
常见问题
有可能会出现过了一阵,还是没有数据,然后从状态里可以看到这样的输出
systemctl status vnstat
提示没有权限
Mar 17 21:16:16 VM-0-3-centos vnstatd[4065]: Error: Unable to open database "/var/lib/vnstat/eth0" for writing: Permission denied
直接更改用户为vnstat 来运行
chown -R vnstat:vnstat /var/lib/vnstat
查看具体程序权限
ll /var/lib/vnstat
Summary
…
Quote
https://blog.csdn.net/qq_32828933/article/details/88656414
https://humdi.net/vnstat/
FEATURED TAGS
RaspberryPi
嵌入式
Git
脚本
python
LeetCode
C++
APM
FreeRTOS
Markdown
Embedded
Linux
Vim
Ubuntu
Tools
STM32
Maya
LPWAN
Graph Theory
Algorithm
PathFind
OMPL
VPS
QT
Router
JS
Chrome
Tampermonkey
API
Java
Spring
MySql
Springboot
Docker
V2ray
TTRSS
Nintendo Switch
Trace
Crack
BLHeli
DSHOT
ESC
Music
C#
EasyCon
Blog
杂谈
Proxy
UAV
GuinnessWorldRecords
NAS
群晖
ZeroTier
Typora
Map
旅游
Log
JSON
Cython
Equip
Goods
Share
DMX512
Blender
Game
AP
Network
CloudFlare
DIY
WIFI
Camera
Diablo
Sensor
SES
QQ
Bot
Python
Vmq
Jenkins
米家
ESP32
Software
C
MT793x
NXP
CH32
OpenWrt
Onion
Copilot
Investment
ChatGPT
Debug
RouterOS
Mikrotik
GitLab
Drone
OpenAI
AI
VS Code
管理
build
Kconfig
CMake
VSCode
Su7Ultra
Car
Cursor