Install vnStat on CentOS to monitor ECS traffic

Source: Internet
Author: User
In addition to the panel provided by the service provider, we can also install vnStat to monitor the upstream and downstream traffic of your VPS or server on a daily basis. the vnStat installation method is simple, which can be divided into compilation and installation or direct installation through the source. 1. Compile and install this method for all Linux releases. first, download vnStat: wgethttp: // humdi.net/vnstat/vnstat-1.11.tar.gz from the official website.

In addition to the panel provided by the service provider, we can also install vnStat to monitor the upstream and downstream traffic of your VPS or server on a daily basis. the vnStat installation method is simple, which can be divided into compilation and installation or direct installation through the source.

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 nomakeCommand, you need to installgccAndmake

Under CentOS:

yum -y install gcc make

In Debian/Ubuntu:

sudo apt-get install gcc make

After compilation and installationifconfig -aView 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 noteth0To change the network card name and/etc/vnstat.confOfInterface "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/vnstatFile, 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.aptInstall:

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. I will open an article separately 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.