Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1743436
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: LINUX

2015-08-31 10:25:03

三个网络工具:
nethogs 可以定位进程占用的网络带宽。
nethogs 我尝试安装在rhel 7上,但是发现epel的repo没有这个软件。只能装在ubuntu 上了。
安装很简单:

点击(此处)折叠或打开

  1. apt-get install nethogs
nethogs 这个工具很小巧好用,manual 也很短。

点击(此处)折叠或打开

  1. Options
  2.        -d delay for refresh rate.

  3.        -h display available commands usage.

  4.        -p sniff in promiscious mode (not recommended).

  5.        -t tracemode.

  6.        -V prints Version info.

  7.        device(s) to monitor. By default eth0 is being used.

  8. INTERACTIVE CONTROL
  9.        m cycle between display modes (kb/s, kb, b, mb)

  10.        r sort by 'received'

  11.        s sort by 'sent'

  12.        q quit

然后是iptraf ,iptraf 的强项在于可以看到所有端口的发包,如果是把Linux当路由器用的时候,会很好用。可以看到每个IP占用的带宽。

点击(此处)折叠或打开

  1. yum install iptraf
manual 也很简单

点击(此处)折叠或打开

  1. OPTIONS
  2.        These options can also be supplied to the command:

  3.        -i iface
  4.               immediately start the IP traffic monitor on the specified interface, or all interfaces if "-i
  5.               all" is specified

  6.        -g immediately start the general interface statistics

  7.        -d iface
  8.               allows you to immediately start the detailed on the indicated interface (iface)

  9.        -s iface
  10.               allows you to immediately monitor TCP and UDP traffic on the specified interface (iface)

  11.        -z iface
  12.               shows packet counts by size on the specified interface

  13.        -l iface
  14.               start the LAN station monitor on the specified interface, or all LAN interfaces if "-l all" is
  15.               specified

  16.        -t timeout
  17.               tells IPTraf to run the specified facility for only timeout minutes. This option is used only
  18.               with one of the above parameters.

  19.        -B redirect standard output to /dev/null, closes standard input, and forks the program into the
  20.               background. Can be used only with one of the facility invocation parameters above. Send the
  21.               backgrounded process a USR2 signal to terminate.

  22.        -L logfile
  23.               allows you to specify an alternate log file name. The default log file name is based on either
  24.               the interface selected (detailed interface statistics, TCP/UDP service statistics, packet size
  25.               breakdown), or the instance of the facility (IP traffic monitor, LAN station monitor). If a
  26.               path is not specified, the log file is placed in /var/log/iptraf

  27.        -L logfile
  28.               allows you to specify an alternate log file name. The default log file name is based on either
  29.               the interface selected (detailed interface statistics, TCP/UDP service statistics, packet size
  30.               breakdown), or the instance of the facility (IP traffic monitor, LAN station monitor). If a
  31.               path is not specified, the log file is placed in /var/log/iptraf

  32.        -f clears all locks and counters, causing this instance of IPTraf to think it
最后一个工具是vnstat:
vnstat 的选项很多,所以这里不列出它的manual,感觉要比上两个工具要复杂一些,参数也更多。

点击(此处)折叠或打开

  1. yum install vnstat

点击(此处)折叠或打开

  1. # Show live trafic
  2. vnstat -l
  3. # Start monitoring the trafic
  4. vnstat -u -i eth0
  5. # Check your daily trafic (but you need to start
  6. # the monitoring and gather the data before you can use it)
  7. vnstat -d
  8. # Monthly
  9. vnstat -m
注意:如果有如下报错:

点击(此处)折叠或打开

  1. eth0: Not enough data available yet.
建议加一个crontab.每5分钟更新下vnstat 的数据库

点击(此处)折叠或打开

  1. */5 * * * * /usr/bin/vnstat -u >/dev/null 2>&1



阅读(1416) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~