µ¼¶Á Äã¿ÉÒÔͨ¹ýÕâÈý¸ö Linux ÍøÂçÃüÁÁ˽âÓйØÄãÍøÂçÁ¬½ÓµÄ´óÁ¿ÐÅÏ¢¡£iftop ͨ¹ý½ø³ÌºÅ¸ú×ÙÍøÂçÁ¬½Ó£¬Nethogs ¿ÉÒÔ¿ìËÙÏÔʾÄĸöÔÚÕ¼ÓÃÄãµÄ´ø¿í£¬¶ø vnstat ×÷Ϊһ¸öºÜºÃµÄÇáÁ¿¼¶ÊØ»¤½ø³ÌÔËÐУ¬¿ÉÒÔËæʱËæµØ¼Ç¼ÄãµÄʹÓÃÇé¿ö¡£
iftop
iftop ¼àÌýÄãÖ¸¶¨µÄÍøÂç½Ó¿Ú£¬²¢ÒÔ top µÄÐÎʽչʾÁ¬½Ó¡£
ÕâÊÇÒ»¸öºÜºÃµÄС¹¤¾ß£¬ÓÃÓÚ¿ìËÙʶ±ðÕ¼ÓᢲâÁ¿Ëٶȣ¬²¢±£³ÖÍøÂçÁ÷Á¿µÄ×ÜÌåÔËÐС£¿´µ½ÎÒÃÇʹÓÃÁ˶àÉÙ´ø¿íÊǷdz£ÁîÈ˾ªÑȵģ¬ÌرðÊǶÔÓÚÎÒÃÇÕâЩ»¹¼ÇµÃʹÓõ绰Ïß¡¢µ÷Öƽâµ÷Æ÷¡¢ÈÃÈ˼â½ÐµÄ Kbit ËٶȺÍÕæʵµÄʵʱ²¨ÌØÂʵÄÀÏÄêÈËÀ´Ëµ¡£ÎÒÃǺܾÃÒÔÇ°¾Í·ÅÆúÁ˲¨ÌØÂÊ£¬×ª¶øʹÓñÈÌØÂÊ¡£²¨ÌØÂʲâÁ¿Ðźű仯£¬ÓÐʱÓë±ÈÌØÂÊÏàͬ£¬µ«´ó¶àÊýÇé¿öϲ»ÊÇ¡£
Èç¹ûÄãÖ»ÓÐÒ»¸öÍøÂç½Ó¿Ú£¬¿ÉÒÔ²»´øÑ¡ÏîÔËÐÐ iftop¡£iftop ÐèÒª root ȨÏÞ£º
$ sudo iftop
µ±ÄãÓжà¸ö½Ó¿Úʱ£¬Ö¸¶¨Òª¼à¿ØµÄ½Ó¿Ú£º
$ sudo iftop -i wlan0
¾ÍÏñ top Ò»Ñù£¬Äã¿ÉÒÔÔÚÔËÐÐʱ¸ü¸ÄÏÔʾѡÏî¡£
h Çл»°ïÖúÆÁÄ»¡£
n Çл»Ãû³Æ½âÎö¡£
s Çл»Ô´Ö÷»úÏÔʾ£¬d Çл»Ä¿±êÖ÷»ú¡£
s Çл»¶Ë¿ÚºÅ¡£
N Çл»¶Ë¿Ú½âÎö¡£ÒªÈ«¿´µ½¶Ë¿ÚºÅ£¬Çë¹Ø±Õ½âÎö¡£
t Çл»Îı¾½çÃ档ĬÈÏÏÔʾÐèÒª ncurses¡£ÎÒÈÏΪÎı¾ÏÔʾ¸üÒ×ÓÚÔĶÁºÍ¸üºÃµÄ×éÖ¯£¨Í¼1£©¡£
p ÔÝÍ£ÏÔʾ¡£
q Í˳ö³ÌÐò¡£
ͼ 1£ºÎı¾ÏÔʾÊǿɶÁµÄºÍ¿É×éÖ¯µÄ¡£
µ±ÄãÇл»ÏÔʾѡÏîʱ£¬iftop »á¼ÌÐø²âÁ¿ËùÓÐÁ÷Á¿¡£Ä㻹¿ÉÒÔÑ¡ÔñÒª¼à¿ØµÄµ¥¸öÖ÷»ú¡£ÄãÐèÒªÖ÷»úµÄ IP µØÖ·ºÍÍøÂçÑÚÂë¡£ÎҺܺÃÆæ Pandora ÔÚÎÒÄÇ¿ÉÁ¯µÄ´ø¿íÖÐÕ¼ÓÃÁ˶àÉÙ£¬ËùÒÔÎÒÏÈÓà dig ÕÒµ½ËüÃÇµÄ IP µØÖ·£º
$ dig A pandora.com [...] ;; ANSWER SECTION: pandora.com. 267 IN A 208.85.40.20 pandora.com. 267 IN A 208.85.40.50
ÍøÂçÑÚÂëÊÇʲô£¿ ipcalc ¸æËßÎÒÃÇ£º
$ ipcalc -b 208.85.40.20 Address: 208.85.40.20 Netmask: 255.255.255.0 = 24 Wildcard: 0.0.0.255 => Network: 208.85.40.0/24
ÏÖÔÚ½«µØÖ·ºÍÍøÂçÑÚÂëÌṩ¸ø iftop£º
$ sudo iftop -F 208.85.40.20/24 -i wlan0
Õâ²»ÊÇÕæµÄÂð£¿ÎҺܾªÑȵط¢ÏÖ£¬ÎÒÕä¹óµÄ´ø¿í¶ÔÓÚ Pandora ºÜ¿íÔ££¬Ã¿Ð¡Ê±Ê¹ÓôóԼʹÓà 500Kb¡£¶øÇÒ£¬Ïñ´ó¶àÊýÁ÷ýÌå·þÎñÒ»Ñù£¬Pandora µÄÁ÷Á¿Ò²ÓзåÖµ£¬ÆäÒÀÀµÓÚ»º´æÀ´»º½â×èÈû¡£
Äã¿ÉÒÔʹÓà -G Ñ¡Ïî¶Ô IPv6 µØÖ·Ö´ÐÐÏàͬ²Ù×÷¡£Çë²ÎÔÄÊÖ²áÒ³Á˽â iftop µÄÆäËû¹¦ÄÜ£¬°üÀ¨Ê¹ÓÃ×Ô¶¨ÒåÅäÖÃÎļþ¶¨ÖÆĬÈÏÑ¡Ï²¢Ó¦ÓÃ×Ô¶¨Òå¹ýÂËÆ÷£¨Çë²ÎÔÄ PCAP-FILTER ×÷Ϊ¹ýÂËÆ÷²Î¿¼£©¡£
Nethogs
µ±ÄãÏëÒª¿ìËÙÁ˽âËÕ¼ÓÃÁËÄãµÄ´ø¿íʱ£¬Nethogs ÊÇ¿ìËÙºÍÈÝÒ׵ġ£ÒÔ root Éí·ÝÔËÐУ¬²¢Ö¸¶¨Òª¼àÌýµÄ½Ó¿Ú¡£ËüÏÔʾÁË¿ÕÏеÄÓ¦ÓóÌÐòºÍ½ø³ÌºÅ£¬ÒÔ±ãÈç¹ûÄãÔ¸ÒâµÄ»°£¬Äã¿ÉÒÔɱËÀËü£º
$ sudo nethogs wlan0 NetHogs version 0.8.1 PID USER PROGRAM DEV SENT RECEIVED 7690 carla /usr/lib/firefox wlan0 12.494 556.580 KB/sec 5648 carla .../chromium-browser wlan0 0.052 0.038 KB/sec TOTAL 12.546 556.618 KB/sec
Nethogs Ñ¡ÏîºÜÉÙ£ºÔÚ kb/s¡¢kb¡¢b ºÍ mb Ö®¼äÑ»·£»Í¨¹ý½ÓÊÕ»ò·¢Ë͵ÄÊý¾Ý°ü½øÐÐÅÅÐò£»²¢µ÷ÕûË¢ÐÂÖ®¼äµÄÑÓ³Ù¡£Çë²ÎÔÄ man nethogs£¬»òÕßÔËÐÐ nethogs -h¡£
vnstat
vnstat ÊÇ×îÈÝÒ×ʹÓõÄÍøÂçÊý¾ÝÊÕ¼¯Æ÷¡£ËüÊÇÇáÁ¿¼¶µÄ£¬²»ÐèÒª root ȨÏÞ¡£Ëü×÷ΪÊØ»¤½ø³ÌÔËÐУ¬²¢¼Ç¼ÄãÍøÂçͳ¼ÆÐÅÏ¢¡£vnstat ÃüÁîÏÔʾÀۼƵÄÊý¾Ý£º
$ vnstat -i wlan0 Database updated: Tue Oct 17 08:36:38 2017 wlan0 since 10/17/2017 rx: 45.27 MiB tx: 3.77 MiB total: 49.04 MiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Oct '17 45.27 MiB | 3.77 MiB | 49.04 MiB | 0.28 kbit/s ------------------------+-------------+-------------+--------------- estimated 85 MiB | 5 MiB | 90 MiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- today 45.27 MiB | 3.77 MiB | 49.04 MiB | 12.96 kbit/s ------------------------+-------------+-------------+--------------- estimated 125 MiB | 8 MiB | 133 MiB |
ËüĬÈÏÏÔʾËùÓеÄÍøÂç½Ó¿Ú¡£Ê¹Óà -i Ñ¡ÏîÑ¡Ôñµ¥¸ö½Ó¿Ú¡£ÒÔÕâÖÖ·½Ê½ºÏ²¢¶à¸ö½Ó¿ÚµÄÊý¾Ý£º
$ vnstat -i wlan0+eth0+eth1
Äã¿ÉÒÔͨ¹ýÒÔϼ¸ÖÖ·½Ê½¹ýÂËÏÔʾ£º
-h ÒÔСʱÏÔʾͳ¼ÆÊý¾Ý¡£
-d ÒÔÌìÊýÏÔʾͳ¼ÆÊý¾Ý¡£
-w ºÍ -m °´ÖܺÍÔÂÏÔʾͳ¼ÆÊý¾Ý¡£
ʹÓà -l Ñ¡Ïî²é¿´ÊµÊ±¸üС£
´ËÃüÁîɾ³ý wlan1 µÄÊý¾Ý¿â£¬²¢Í£Ö¹¼à¿ØËü£º
$ vnstat -i wlan1 --delete
´ËÃüÁîΪÍøÂç½Ó¿Ú´´½¨±ðÃû¡£´ËÀýʹÓà Ubuntu 16.04 ÖеÄÒ»¸öÆæ¹ÖµÄ½Ó¿ÚÃû³Æ£º
$ vnstat -u -i enp0s25 --nick eth0
ĬÈÏÇé¿öÏ£¬vnstat ¼àÊÓ eth0¡£Äã¿ÉÒÔÔÚ /etc/vnstat.conf Öиü¸Ä´ËÄÚÈÝ£¬»òÔÚÖ÷Ŀ¼Öд´½¨×Ô¼ºµÄ¸öÈËÅäÖÃÎļþ¡£Çë²Î¼û man vnstat ÒÔ»ñµÃÍêÕûµÄ²Î¿¼¡£
Ä㻹¿ÉÒÔ°²×° vnstati ´´½¨¼òµ¥µÄ²Êɫͼ£¨Í¼2£©£º
$ vnstati -s -i wlx7cdd90a0a1c2 -o vnstat.png
ͼ 2£ºÄã¿ÉÒÔʹÓà vnstati ´´½¨¼òµ¥µÄ²Êɫͼ±í¡£
ÓйØÍêÕûÑ¡ÏÇë²Î¼û man vnstati¡£
via: https://www.linux.com/learn/intro-to-linux/2017/10/3-simple-excellent-linux-network-monitors
±¾ÎÄתÔØ×Ô£ºhttp://www.linuxprobe.com/linux-network-monitor.html
Ãâ·ÑÌṩ×îÐÂLinux¼¼Êõ½Ì³ÌÊé¼®£¬Îª¿ªÔ´¼¼Êõ°®ºÃÕßŬÁ¦×öµÃ¸ü¶à¸üºÃ£¬¿ªÔ´Õ¾µã£ºhttp://www.linuxprobe.com/
hasson ÓÚ 2017-12-31 18:48:32·¢±í:
ѧϰѧϰ
Ronny ÓÚ 2017-11-13 12:49:14·¢±í:
3¸ö ÓÅÐãLinux ÍøÂç¼àÊÓÆ÷£¡