1. Compile and install this method for all Linux releases. first, download vnStat: wgethttp: // packages from the official website.
1. use compilation and installation
This method is applicable to all Linux releases.
First, download vnStat from the official website:
wget http://humdi.net/vnstat/vnstat-1.11.tar.gz
Decompress:
tar xvzf vnstat-1.11.tar.gz
Enter The Directory:
cd vnstat-1.11
Compile and install:
make && make install
If nomake
Command, you need to installgcc
Andmake
Under CentOS:
yum -y install gcc make
In Debian/Ubuntu:
sudo apt-get install gcc make
After compilation and installationifconfig -a
View your network card, usually as follows:
eth0 Link encap:Ethernet HWaddr 00:16:3e:a3:c3:9c inet addr:10.0.0.10 Bcast:10.0.0.63 Mask:255.255.255.192 inet6 addr: fe80::216:3eff:fea3:c39c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:136503286 errors:0 dropped:189069 overruns:0 frame:0 TX packets:53219265 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17989373908 (17.9 GB) TX bytes:24055536418 (24.0 GB) Interrupt:32
Then your VPS or server NIC iseth0
Then generate the vnStat database:
/usr/bin/vnstat -u -i eth0
If your Nic is noteth0
To change the network card name and/etc/vnstat.conf
OfInterface "eth0"
Your nic name.
Then you can start vnStat:
vnstatd -d
There is a problem with this method, that is, occasionally the traffic statistics will be stopped, especially in CentOS. when the traffic database is large, bugs will often occur. we recommend that you use the source installation here.
II. use the source to install vnStat
In CentOS, you need to import a third-party EPEL source.
Then install vnStat
yum -y install vnstat
Generate database
vnstat -u -i eth0
Modify/etc/cron.d/vnstat
File, the last line is changed
*/5 * * * * root /usr/sbin/vnstat.cron
Set vnStat to run automatically after restart
chkconfig vnstat on
Debian/Ubuntu does not need to import third-party sources.apt
Install:
sudo apt-get install vnstat
Then Grant permissions
sudo chmod o+x /usr/bin/vnstat
sudo chmod o+wx /var/lib/vnstat/
Then generate the database
vnstat -u -i eth0
After the installation is complete, you have to like the Debian system. the subsequent actions have been automatically set for you.
III. common vnStat usage
View current real-time traffic
vnstat -l
View daily traffic statistics
vnstat -d
View Monthly Traffic Statistics
vnstat -m
View traffic reports
vnstat
View the real-time traffic of a specific network adapter
vnstat -l -i eth0
In addition, the traffic used does not have much to do with the bandwidth you use.