Mark's blog 这是 Mark 的个人博客,记录些东西。

vnstat 流量统计(2.8版本)安装教程

转载: https://blog.51cto.com/heyong/5148951 https://www.tecmint.com/install-vnstat-and-vnstati-to-monitor-linux-network-traffic/

备份: https://raw.githubusercontent.com/jys11111/jys/main/vnstat-2.6.tar.gz https://raw.githubusercontent.com/jys11111/jys/main/vnstat-2.8.tar.gz

先决条件

make C compiler user with access to kernel interface statistics usually available by default but can be restricted for example by grsecurity and similar security enhancement suites or settings sqlite3 (library and development files) libgd (optional, image output) check (optional, test suite) pkg-config (optional, for check detection) autotools (optional, for recreating configure and makefiles)

安装

Centos:

yum -y install gcc automake autoconf libtool make
yum install gd gd-devel sqlite sqlite-devel 
#如果上面两个装了还不行,在运行这行
#yum group install "Development Tools"

wget https://github.com/vergoh/vnstat/releases/download/v2.8/vnstat-2.8.tar.gz

tar zxf vnstat-2.8.tar.gz

cd vnstat-2.8

./configure --prefix=/usr --sysconfdir=/etc && make && make install

mkdir /var/lib/vnstat

chmod -R 777 /var/lib/vnstat/

配置system启动

cp -v examples/systemd/vnstat.service /etc/systemd/system/
systemctl start vnstat
systemctl enable vnstat
systemctl restart vnstat

注意:如果是较旧的版本使用下面的命令

cp -v examples/systemd/simple/vnstat.service /etc/systemd/system/
systemctl enable vnstat
systemctl start vnstat

其它系统

Debian:

apt-get install libsqlite3-dev
apt-get install sqlite3
apt-get install make
# 下面这条不是必须
#apt-get install build-essential

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 start vnstat
systemctl enable vnstat

Red Hat / CentOS:

cp -v examples/init.d/redhat/vnstat /etc/init.d/
chkconfig vnstat on
service vnstat start

upstart:

cp -v examples/upstart/vnstat.conf /etc/init/
initctl start vnstat

报错

configure: error: could not find required sqlite3 library:

#Centos
yum install -y sqlite-devel

# Debian/Ubuntu
apt-get install sqlite3
apt-get install libsqlite3-dev
By Mark On