FREE、TOPなどでもシステム状況を把握して問題解決やリソースのプランニングが可能だが、
他にもいくつか参考になるコマンドがあるのでメモ。

CPU使用率TOP10
ps auxw | sort -k3 -nr | head -n 10
cpu利用率

MEM使用率TOP10
ps auxw | sort -k4 -nr | head -n 10
mem利用率

パフォーマンス確認に便利なdstat
Usage: dstat [-afv] [options..] [delay [count]]

インストール
[root@ip-xx-xxx-xx-xxx ec2-user]# yum install dstat
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.ap-northeast-1.amazonaws.com
* amzn-updates: packages.ap-northeast-1.amazonaws.com
amzn-main | 2.1 kB 00:00
amzn-updates | 2.3 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package dstat.noarch 0:0.7.0-1.5.amzn1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
dstat noarch 0.7.0-1.5.amzn1 amzn-main 182 k

Transaction Summary
=======================================================================================
Install 1 Package(s)

Total download size: 182 k
Installed size: 660 k
Is this ok [y/N]: y
Downloading Packages:
dstat-0.7.0-1.5.amzn1.noarch.rpm | 182 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : dstat-0.7.0-1.5.amzn1.noarch 1/1

Installed:
dstat.noarch 0:0.7.0-1.5.amzn1

Complete!
[root@ip-xx-xxx-xx-xxx ec2-user]#

dstat –top-bioで最もブロックI/Oしているプロセス確認。
dstat –top-ioで最もI/Oが多いプロセスを確認。

[root@ip-xx-xxx-xx-xxx ec2-user]# dstat --top-bio
—-most-expensive—-
block i/o process
init 66k 726B

[root@ip-xx-xxx-xx-xxx ec2-user]# dstat --top-io
—-most-expensive—-
i/o process
bash 82k 1351B
sshd: ec2-u 146B 248B
sshd: ec2-u 78B 168B
sshd: ec2-u 78B 168B
sshd: ec2-u 78B 168B
sshd: ec2-u 78B 168B
sshd: ec2-u 78B 168B

dstat –tcp でTCPコネクション確認
dstat –net でネットワーク確認

[ip-xx-xxx-xx-xxx]#dstat --tcp --net

net状態

[root@ip-xx-xxx-xx-xxx ec2-user]# dstat --top-cpu
-most-expensive-
cpu process
httpd 0.1
mysqld 1.0

[root@ip-xx-xxx-xx-xxx ec2-user]# dstat --net
-net/total-
recv send
0 0
80B 308B
40B 260B
40B 260B
40B 260B
40B 260B
5925B 35k
1710B 24k
4120B 37k
256B 298B
40B 154B
[root@ip-xx-xxx-xx-xxx ec2-user]#

CPUとネットの状況を同時に確認

[root@ip-xx-xxx-xx-xxx ec2-user]# dstat -a
—-total-cpu-usage—- -dsk/total- -net/total- —paging– —system–
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
1 0 98 0 0 0| 92k 12k| 0 0 | 0 0 | 36 66
0 0 100 0 0 0| 0 0 | 80B 916B| 0 0 | 20 46
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 18 44
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 18 46
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 20 46
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 19 47
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 16 42
0 0 100 0 0 0| 0 0 | 40B 452B| 0 0 | 19 46
1 0 99 0 0 0| 0 0 | 40B 452B| 0 0 | 18 43
[root@ip-xx-xxx-xx-xxx ec2-user]#

-a, --all equals -cdngy (default)
all

dtatオプション

[ip-xx-xxx-xx-xxx]#dstat –help
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
-c, –cpu enable cpu stats
-C 0,3,total include cpu0, cpu3 and total
-d, –disk enable disk stats
-D total,hda include hda and total
-g, –page enable page stats
-i, –int enable interrupt stats
-I 5,eth2 include int5 and interrupt used by eth2
-l, –load enable load stats
-m, –mem enable memory stats
-n, –net enable network stats
-N eth1,total include eth1 and total
-p, –proc enable process stats
-r, –io enable io stats (I/O requests completed)
-s, –swap enable swap stats
-S swap1,total include swap1 and total
-t, –time enable time/date output
-T, –epoch enable time counter (seconds since epoch)
-y, –sys enable system stats

–aio enable aio stats
–fs, –filesystem enable fs stats
–ipc enable ipc stats
–lock enable lock stats
–raw enable raw stats
–socket enable socket stats
–tcp enable tcp stats
–udp enable udp stats
–unix enable unix stats
–vm enable vm stats

–plugin-name enable plugins by plugin name (see manual)
–list list all available plugins

-a, –all equals -cdngy (default)
-f, –full automatically expand -C, -D, -I, -N and -S lists
-v, –vmstat equals -pmgdsc -D total

–bw, –blackonwhite change colors for white background terminal
–float force float values on screen
–integer force integer values on screen
–nocolor disable colors (implies –noupdate)
–noheaders disable repetitive headers
–noupdate disable intermediate updates
–output file write CSV output to file

delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)

[ip-xx-xxx-xx-xxx]#

上記オプションを適切に使い分けて、最適なシステム状況診断と
対応が出来るようにしておくと良さそうです。

dstat --cpu --mem --disk --page --int --load --net
general

dstat -N eth0
interface

dstat --time --proc --swap --sys --ipc
date

dstat --full
full

dstat --vmstat
vmstat


--integer 整数値を表示します
--nocolor カラー表示を無効にします
--noheaders ヘッダー表示を無効にします
--noupdate 仲介更新を無効にします
--output file 出力結果を CSV ファイルに書き出します

参考
Dstat: Versatile resource statistics tool

Comments are closed.

Post Navigation