CentOS7 で iftop と bmon を利用する備忘録

Networks
Photo by hyt.

Unix系のシステムでネットワークの各インターフェースの利用状況をリアルタイムに見ることのできるプログラムとして,bmon と iftop はなかなか便利です.しかし,CentOS の標準リポジトリには双方とも含まれてません.

それぞれ配布元は,bmon が

GitHub - tgraf/bmon: bandwidth monitor and rate estimator
bandwidth monitor and rate estimator. Contribute to tgraf/bmon development by creating an account on GitHub.

で,iftop が

iftop: display bandwidth usage on an interface

で,ソースコードから入れるのも一つの手ですが,CentOS の場合,EPEL

Extra Packages for Enterprise Linux (EPEL)
Learn more about Fedora Linux, the Fedora Project & the Fedora Community.

に含まれているので,

CentOS 7 : 初期設定 : リポジトリ追加 : Server World
CentOS 7 初期設定 リポジトリ追加

を参考に

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ sudo yum -y install epel-release
$ sudo sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo
$ sudo yum -y install epel-release $ sudo sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo
$ sudo yum -y install epel-release
$ sudo sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo

として,EPEL を Centos7 から利用できるように設定して,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ sudo yum -y install bmon iftop
$ sudo yum -y install bmon iftop
$ sudo yum -y install bmon iftop

で OK.

なお,bmon は普通のユーザー権限で使えますが,iftop は適切な権限が無いと使えないことに注意が必要です.私の場合は面倒なので,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ sudo iftop -i eth0
$ sudo iftop -i eth0
$ sudo iftop -i eth0

のようにして使ってます.

実際に実行してみたイメージは bmon が,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
eth0 bmon 3.6
Interfaces │ RX bps pps %│ TX bps pps %
lo │ 0 00 0
qdisc none (noqueue)0 00 0
→th0 │ 3.36KiB 4034.62KiB 52
qdisc none (mq)0 034.62KiB 52
class :1 (mq)0 0 │ 741B 2
qdisc none (pfifo_fast)0 03.56GiB 4.29G
class :2 (mq)0 033.89KiB 50
qdisc none (pfifo_fast)0 0 │16777090TiB 4.29G
───────────────────────────────┴───────────────────────┴────────────────────────
KiB (RX Bytes/second)
14.97 .........................|..................................
12.47 .........................|.................................|
9.98 .........................|.......................|.........|
7.48 .........................|......................||.|.......|
4.99 ..||.|..||...|||..|.|.|.||.|..|..||||...||..||..||||.||||..|
2.49 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 5 10 15 20 25 30 35 40 45 50 55 60
KiB (TX Bytes/second)
53.06 .........................|..................................
44.22 .......|............|..|.|........|..|...........|.....|.|.|
35.38 ||||||||||||.|||||||||||||.||||||||.||||||||||||||||||||||||
26.53 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
17.69 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8.84 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 5 10 15 20 25 30 35 40 45 50 55 60
───────────────────── Press d to enable detailed statistics ────────────────────
─────────────────── Press i to enable additional information ───────────────────
Sat Nov 18 22:15:50 2017 Press ? for help
eth0 bmon 3.6 Interfaces │ RX bps pps %│ TX bps pps % lo │ 0 0 │ 0 0 qdisc none (noqueue) │ 0 0 │ 0 0 →th0 │ 3.36KiB 40 │ 34.62KiB 52 qdisc none (mq) │ 0 0 │ 34.62KiB 52 class :1 (mq) │ 0 0 │ 741B 2 qdisc none (pfifo_fast)│ 0 0 │ 3.56GiB 4.29G class :2 (mq) │ 0 0 │ 33.89KiB 50 qdisc none (pfifo_fast)│ 0 0 │16777090TiB 4.29G ───────────────────────────────┴───────────────────────┴──────────────────────── KiB (RX Bytes/second) 14.97 .........................|.................................. 12.47 .........................|.................................| 9.98 .........................|.......................|.........| 7.48 .........................|......................||.|.......| 4.99 ..||.|..||...|||..|.|.|.||.|..|..||||...||..||..||||.||||..| 2.49 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 1 5 10 15 20 25 30 35 40 45 50 55 60 KiB (TX Bytes/second) 53.06 .........................|.................................. 44.22 .......|............|..|.|........|..|...........|.....|.|.| 35.38 ||||||||||||.|||||||||||||.||||||||.|||||||||||||||||||||||| 26.53 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 17.69 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 8.84 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 1 5 10 15 20 25 30 35 40 45 50 55 60 ───────────────────── Press d to enable detailed statistics ──────────────────── ─────────────────── Press i to enable additional information ─────────────────── Sat Nov 18 22:15:50 2017 Press ? for help
eth0                                                                  bmon 3.6
Interfaces                     │ RX bps       pps     %│ TX bps       pps     %
   lo                          │      0         0      │      0         0
    qdisc none (noqueue)       │      0         0      │      0         0
 →th0                         │   3.36KiB     40      │  34.62KiB     52
    qdisc none (mq)            │      0         0      │  34.62KiB     52
      class :1 (mq)            │      0         0      │    741B        2
        qdisc none (pfifo_fast)│      0         0      │   3.56GiB   4.29G
      class :2 (mq)            │      0         0      │  33.89KiB     50
        qdisc none (pfifo_fast)│      0         0      │16777090TiB   4.29G
───────────────────────────────┴───────────────────────┴────────────────────────
     KiB                      (RX Bytes/second)
   14.97 .........................|..................................
   12.47 .........................|.................................|
    9.98 .........................|.......................|.........|
    7.48 .........................|......................||.|.......|
    4.99 ..||.|..||...|||..|.|.|.||.|..|..||||...||..||..||||.||||..|
    2.49 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
         1   5   10   15   20   25   30   35   40   45   50   55   60
     KiB                      (TX Bytes/second)
   53.06 .........................|..................................
   44.22 .......|............|..|.|........|..|...........|.....|.|.|
   35.38 ||||||||||||.|||||||||||||.||||||||.||||||||||||||||||||||||
   26.53 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   17.69 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    8.84 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
         1   5   10   15   20   25   30   35   40   45   50   55   60
───────────────────── Press d to enable detailed statistics ────────────────────
─────────────────── Press i to enable additional information ───────────────────
 Sat Nov 18 22:15:50 2017                                      Press ? for help

な感じで,iftop が,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
1.91Mb 3.81Mb 5.72Mb 7.63Mb 9.54Mb
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────
192.168.100.150 => 192.168.100.38 5.31Kb 4.72Kb 4.79Kb
<= 274Kb 258Kb 258Kb
*************.local => 192.168.100.3 3.61Kb 18.8Kb 13.3Kb
<= 7.68Kb 9.55Kb 9.67Kb
192.168.100.170 => 192.168.100.38 0b 0b 0b
<= 0b 4.68Kb 2.13Kb
239.255.255.250 => 192.168.100.121 0b 0b 0b
<= 644b 386b 293b
224.0.0.251 => 192.168.100.170 0b 0b 0b
<= 0b 367b 167b
239.255.255.250 => 192.168.100.170 0b 0b 0b
<= 0b 98b 44b
───────────────────────────────────────────────────────────────────────────────
TX: cum: 36.5KB peak: 37.9Kb rates: 3.61Kb 18.8Kb 13.3Kb
RX: 757KB 296Kb 288Kb 278Kb 275Kb
TOTAL: 793KB 312Kb 291Kb 297Kb 288Kb
1.91Mb 3.81Mb 5.72Mb 7.63Mb 9.54Mb └───────────────┴───────────────┴───────────────┴───────────────┴─────────────── 192.168.100.150 => 192.168.100.38 5.31Kb 4.72Kb 4.79Kb <= 274Kb 258Kb 258Kb *************.local => 192.168.100.3 3.61Kb 18.8Kb 13.3Kb <= 7.68Kb 9.55Kb 9.67Kb 192.168.100.170 => 192.168.100.38 0b 0b 0b <= 0b 4.68Kb 2.13Kb 239.255.255.250 => 192.168.100.121 0b 0b 0b <= 644b 386b 293b 224.0.0.251 => 192.168.100.170 0b 0b 0b <= 0b 367b 167b 239.255.255.250 => 192.168.100.170 0b 0b 0b <= 0b 98b 44b ─────────────────────────────────────────────────────────────────────────────── TX: cum: 36.5KB peak: 37.9Kb rates: 3.61Kb 18.8Kb 13.3Kb RX: 757KB 296Kb 288Kb 278Kb 275Kb TOTAL: 793KB 312Kb 291Kb 297Kb 288Kb
                1.91Mb          3.81Mb          5.72Mb          7.63Mb    9.54Mb
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────
192.168.100.150            => 192.168.100.38             5.31Kb  4.72Kb  4.79Kb
                           <=                             274Kb   258Kb   258Kb
*************.local        => 192.168.100.3              3.61Kb  18.8Kb  13.3Kb
                           <=                            7.68Kb  9.55Kb  9.67Kb
192.168.100.170            => 192.168.100.38                0b      0b      0b
                           <=                               0b   4.68Kb  2.13Kb
239.255.255.250            => 192.168.100.121               0b      0b      0b
                           <=                             644b    386b    293b
224.0.0.251                => 192.168.100.170               0b      0b      0b
                           <=                               0b    367b    167b
239.255.255.250            => 192.168.100.170               0b      0b      0b
                           <=                               0b     98b     44b
───────────────────────────────────────────────────────────────────────────────
TX:             cum:   36.5KB   peak:   37.9Kb  rates:   3.61Kb  18.8Kb  13.3Kb
RX:                     757KB            296Kb            288Kb   278Kb   275Kb
TOTAL:                  793KB            312Kb            291Kb   297Kb   288Kb

の様な感じです.

bmon は Windows のタスクマネージャーのネットワーク版みたいな感じで,iftop は簡易的なネットワークアナライザとして使えるのが良いところですね.

以上!

NetworksServer
スポンサーリンク
Following hyt!
タイトルとURLをコピーしました