lost and found ( for me ? )

Showing posts with label nethogs. Show all posts
Showing posts with label nethogs. Show all posts

Fedora 16 : small tips : monitoring tools : nethogs , latencytop , atop



[root@fc16 ~]# cat /etc/fedora-release
Fedora release 16 (Verne)

[root@fc16 ~]# uname -ri
3.3.1-3.fc16.x86_64 x86_64

[ nethogs ]

nethogs shows network bandwidth per process
You might identify which processes are using how much bandwidth.

install nethogs via yum
[root@fc16 ~]# yum install nethogs -y


nethogs “device name”



[ latencytop ]

latencytop displays system latency , for example , what kind of latency is occurring in your system , identify the cause of latency in your system.



[root@fc16 ~]# yum install -y latencytop

just type latencytop
# latencytop



[ atop ]

atop is a similar to “top”

# yum install -y atop

just type “atop”



write the output of "atop" to a file

[root@fc16 ~]# atop -w atop.raw  10 3

atop -w “filename” “interval” “# of samples”


[root@fc16 ~]# file atop.raw
atop.raw: data

read the file
[root@fc16 ~]# atop -r atop.raw

You might want to use atop in combination with cron when monitoring your system periodically.

iftop , nethogs , iptraf

アプリケーションごとに、どのくらいネットワークを使用しているかチェックできるツールないかなと探してたら、iftop , nethogs , iptraf というツールがあったので使ってみた。
使った印象として、iptraf かnethogs がアプリケーション毎のトラフィックチェックに向いていそう。

iptraf:

TCP , UDP ポート単位に表示できるのでこれでチェックできそう。
フィルタ、ログなど、設定できる項目が多数ある。

iftop:

指定したポートごとに分けて表示されないので、複数ポートをまとめてチェックするのは難しそう。
複数 iftop を実行すればできそうだが、負荷が気になる。

nethogs:

プロセス毎なので、Apacheのように複数プロセスを起動するアプリは、アプリが1つ(のように見えても)、プロセスの数だけ表示される。合算すれば問題ないと思う。

[ iftop ]

root@ubuntu:~# apt-get install iftop

シンプルな使い方

-n は DNS lookup しないようにする。

root@ubuntu:~# iftop -n -i eth0


設定をファイルに書くこともできる。

root@ubuntu:~# cat iftop.cfg            
interface: eth0
dns-resolution: no
hide-destination: yes
hide-source: yes
log-scale: yes

root@ubuntu:~# iftop -c iftop.cfg


フィルタも書ける。

dst host ホスト名
dst net ネットワーク
dst port ポート番号
dst portrange 開始ポート番号-終了ポート番号
src host ホスト名
src net ネットワーク
src port ポート番号
src portrange 開始ポート番号-終了ポート番号
gateway ゲートウェイ
ip proto プロトコル


コンフィグファイルに filter-code を複数かけるけど、別々(下記の場合TCP 25 と 80 別々)ではなく、まとめてでちゃうな。。

root@ubuntu:~# cat iftop.cfg               
interface: eth0
dns-resolution: no
hide-destination: no
hide-source: no
log-scale: yes
filter-code: dst port 25
filter-code: dst port 80

[ nethogs ]

root@ubuntu:~# apt-get install nethogs

root@ubuntu:~# nethogs eth0

プロセス毎だから、アプリケーション毎ではない。
Apache みたく複数プロセスを起動するものは、プロセス毎でててくるので、合算する必要がある。


-t トレースモード
-d 表示間隔 ( 秒: デフォルト1秒 )

[ iptraf ]

  #  apt-get install iptraf
  #  iptraf


各種設定


テキストにログを出力


root@ubuntu:~# cat /var/log/iptraf/ip_traffic-1.log
Wed Oct  6 10:15:14 2010; ******** IP traffic monitor started ********
Wed Oct  6 10:15:14 2010; TCP; eth0; 1500 bytes; from 192.168.122.112:22 to 192.168.122.1:36519; first packet
Wed Oct  6 10:15:14 2010; TCP; eth0; 52 bytes; from 192.168.122.1:36519 to 192.168.122.112:22; first packet