Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vnStat tools in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use vnStat tools in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

VnStat is used in Linux or BSD platform to monitor the traffic of network card. Because it is not based on network packet sniffing but based on / proc analysis. Now that vnStat has an vnstat PHP frontend extension, you can call the data monitored by vnStat directly in the form of PHP scripts.

Here are the specific installation steps:

Download:

Wget http://soft.vpser.net/status/vnstat/vnstat-1.9.tar.gz

Decompress:

Tar xvzf vnstat-1.9.tar.gz

Enter the directory:

Cd vnstat-1.9

Compile and install:

Make

Make install

If compiled on a 64-bit platform, use the make 64bit command

So the vnstat is installed.

Let's talk about the working running configuration of vnstat:

Download the latest version of vnstat PHP frontend

Address: http://www.sqweek.com/sqweek/fil... Ontend-1.4.1.tar.gz

The unzipped folder is renamed vnstat, and then uploaded to the root directory of a website, so that it can be accessed by http://www.mydomain.com/vnstat, and the page will come out, but there is no data at this time, because the system has to generate data.

Establish a traffic database:

Ifconfig instruction to check the Nic to be monitored, assuming only eth0

Then generate the database:

/ usr/local/bin/vnstat-u-I eth0

Then update the database regularly through cron:

In fact, when you install vnstat, you have already installed the cron,crontab content of vnstat in / etc/cron.d/vnstat.

The content is:

# / etc/cron.d/vnstat: crontab entries for the vnstat package

0-55 root if 5 * root if [- x / usr/bin/vnstat] & & [`ls / var/lib/vnstat/ | wc-l`-ge 1]; then / usr/bin/vnstat-u

; fi

0-55 dumpdb 5 * root / usr/bin/vnstat-dumpdb-I eth0 > / data/vnstat/vnstat_dump_eth0

The first behavior is automatically specified during installation.

The second line is to update the eth0 data, dump out a file, to php access interface.

Here the vnstat_dump_eth0 file name that comes out of dump has a rule.

There are instructions in the config.php in the vnstat_php_frontend-1.4.1.tar.gz bag.

Finally, edit the vnstat/config.php file and change the data directory to / data/vnstat

That is:

$data_dir ='/ data/vnstat'

Specify 1 network card to be monitored:

/ / list of network interfaces monitored by vnStat

/ / $iface_list = array ('eth0',' eth2', 'sixxs')

$iface_list = array ('eth0',)

/ / will be displayed instead

/ /

$iface_title ['eth0'] =' Internal'

/ / $iface_title ['eth2'] =' Internet'

/ / $iface_title ['sixxs'] =' SixXS IPv6'

After all this is done, if you visit it with www.mydomain.com/vnstat/ now, you will find that there are traffic statistics, and the statistical data will be updated every 5 minutes.

These are all the contents of this article entitled "how to use vnStat tools in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report