Ò»£¬ÏÂÔØ°²×°
VnstatÊÇLinuxÖÐÒ»¸öÇ¿´óµÄÁ÷Á¿¼à²â¹¤¾ß£¬ÀûÓÃweb½çÃæ½øÐв鿴¸üÖ±¹Û¡£
wget http://humdi.net/vnstat/vnstat-1.10.tar.gz tar xvf ../software/vnstat-1.10.tar.gz cd vnstat-1.10/ make make install
¶þ£¬vnstatÃüÁîµÄʹÓÃ
[root@www ~]# vnstat ¨Chelp vnStat 1.10 by Teemu Toivola <tst at iki dot fi> -q, ¨Cquery query database -h, ¨Chours show hours -d, ¨Cdays show days -m, ¨Cmonths show months -w, ¨Cweeks show weeks -t, ¨Ctop10 show top10 -s, ¨Cshort use short output -u, ¨Cupdate update database -i, ¨Ciface select interface (default: eth0) -?, ¨Chelp short help -v, ¨Cversion show version -tr, ¨Ctraffic calculate traffic -ru, ¨Crateunit swap configured rate unit -l, ¨Clive show transfer rate in real time See also ¡°¨Clonghelp¡± for complete options list and ¡°man vnstat¡±.
ͨ¹ýifconfig²é¿´Íø¿¨Ãû³Æ£¬È磬eth0£¬eth1µÈ
È»ºóͨ¹ý£º
vnstat -u -i eth0
vnstat -u -i eth1
À´Éú³ÉÊý¾Ý¿â¡£
»òÕßͨ¹ý£º
vnstat -u
×Ô¶¯Éú³ÉËùÓÐÍø¿¨µÄ¡£
¿ÉÒÔͨ¹ýÃüÁîÀ´ÊµÊ±²é¿´Á÷Á¿
vnstat -l -i eth0 £¨³£Óã©
ÈçÏÂͼ£º
Èý£¬Í¨¹ývnStat PHP frontendÀ´¿ÉÊÓ»¯²é¿´Á÷Á¿Í¼
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz tar xvf vnstat_php_frontend-1.5.1.tar.gz mv vnstat_php_frontend-1.5.1 vnstat cd vnstat/ vim config.php
ÐÞ¸Äconfig.php£¬½«ÀïÃæµÄÄÚÈÝÐ޸ijÉÈçÏ£º
ÓïÑÔÏÔʾ£º
$locale = ¡®en_US.UTF-8¡ä;
$language = ¡®en¡¯;
Íø¿¨½Ó¿Ú£º
$iface_list = array(¡®eth0¡ä);
Èç¹ûÓжà¸öÍø¿¨½Ó¿Ú£¬ÒªÐ޸ijÉÀàËÆÈçÏ£º
$iface_list = array(¡®eth0¡ä, ¡®eth1¡ä);
½Ó¿ÚÃû³Æ£¬¸ù¾ÝÍø¿¨¸öÊýÌí¼Ó£¬¿É×ÔÐж¨Ò壺
$iface_title['eth0'] = ¡®My_eth0¡ä;
$iface_title['eth1'] = ¡®My_eth1¡ä;
·¾¶£º
$vnstat_bin = ¡®/usr/bin/vnstat¡¯;
$data_dir = ¡®/var/lib/vnstat/¡¯;
»æͼ·½Ê½£º
$graph_format=¡¯png¡¯;
ÕâÀïÒ»¶¨ÒªÓÃpng,·ñÔòÓÃĬÈϵÄÔÚIEÏ»ῴ²»µ½Í¼¡£
Ìí¼Ó¼Æ»®ÈÎÎñ£º
#crontab -e
*/1 * * * * /usr/bin/vnstat ¨Cu
×îºó¼ÇµÃÌí¼ÓnginxÅäÖãº
server { listen 80; server_name my_vnstat.com ; index index.html index.htm index.php; root /data/web/vnstat; charset utf-8; expires 2h; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:10080; fastcgi_index index.php; include fcgi.conf; expires off; } access_log off; }
Ч¹ûÈçÏÂ
ÆÀÂÛ