Linux Install Vnstat monitor VPS server traffic

Source: Internet
Author: User
Tags chmod vps vps server

First, use the compile installation

This method is suitable for all Linux distributions

First, download Vnstat from the official website:

wget http://humdi.net/vnstat/vnstat-1.11.tar.gz
Extract:

Tar xvzf vnstat-1.11.tar.gz
Enter directory:

CD vnstat-1.11
Compile Installation:

Make && make install
If you do not have the make command, you need to install GCC and make

CentOS under:

Yum-y Install GCC make
Debian/ubuntu under:

sudo apt-get install gcc make
After compiling the installation, you can view your network card through ifconfig-a, which usually shows the following:

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's NIC is eth0

Then generate the Vnstat database:

/usr/bin/vnstat-u-I. eth0
If your network card is not eth0, then modify it to the appropriate network card name and modify the/etc/vnstat.conf Interface "eth0" for your network card name.

You can then start Vnstat:

Vnstatd-d
This method has a problem, that is, occasionally stop statistical traffic, especially under the CentOS, when the traffic database is large, there will often be bugs, where we recommend the use of source installation.

Second, the use of source installation Vnstat

CentOS need to import a third party Epel source, concrete method touch here

Then install Vnstat

Yum-y Install Vnstat
Building a Database

Vnstat-u-I. eth0
Modifies the/etc/cron.d/vnstat file, and the last line is changed to

*/5 * * * * Root/usr/sbin/vnstat.cron
Set Vnstat to run automatically after reboot

Chkconfig Vnstat on
Debian/ubuntu do not need to import a third-party source, directly with apt installation can:

sudo apt-get install Vnstat
Then give permission

sudo chmod o+x/usr/bin/vnstat
sudo chmod o+wx/var/lib/vnstat/
Then build the database

Vnstat-u-I. eth0
Installation finished, have to praise the Debian department, the following actions have been automatically set up for you.

Three, Vnstat common use method

View current Live 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 card

Vnstat-l-I. eth0
In addition, the use of traffic and the bandwidth you use is not much of a relationship, I will open a separate article to illustrate the relationship between traffic and bandwidth

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.