CPUの使用率を確認するコマンド
負荷確認だけでなく、RPSやRFSとか設定するときに便利かも・・
TOPコマンドを使用
#top top - 11:51:18 up 5 days, 2:18, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 93 total, 2 running, 91 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 759136 total, 129716 free, 223176 used, 406244 buff/cache KiB Swap: 2098172 total, 2093548 free, 4624 used. 354960 avail Mem
普通にTOPだとCPUの平均が表示される。CPUのコア毎の負荷を表示させるには「1」を押す
#top top - 11:55:47 up 54 min, 2 users, load average: 0.00, 0.01, 0.03 Tasks: 126 total, 1 running, 125 sleeping, 0 stopped, 0 zombie %Cpu0 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu2 : 0.3 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu3 : 0.0 us, 0.3 sy, 0.0 ni, 99.3 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 1016488 total, 821904 free, 82600 used, 111984 buff/cache KiB Swap: 1048572 total, 1048572 free, 0 used. 811404 avail Mem
sarコマンド使用
sarコマンドを使用するには「sysstat」パッケージが必要。
#yum install -y sysstat ~ インストール: sysstat.x86_64 0:10.1.5-7.el7 完了しました!
5秒更新で表示
#sar -p 5 11時56分55秒 CPU %user %nice %system %iowait %steal %idle 11時57分00秒 all 0.00 0.00 0.00 0.00 0.00 100.00
CPUコア毎に表示(5秒更新)
#sar -u -P ALL 5 Linux 3.10.0-327.18.2.el7.x86_64 (centos1) 2016年07月25日 _x86_64_ (4 CPU) 12時01分25秒 CPU %user %nice %system %iowait %steal %idle 12時01分30秒 all 0.00 0.00 0.00 0.00 0.00 100.00 12時01分30秒 0 0.00 0.00 0.00 0.00 0.00 100.00 12時01分30秒 1 0.00 0.00 0.00 0.00 0.00 100.00 12時01分30秒 2 0.00 0.00 0.00 0.00 0.00 100.00 12時01分30秒 3 0.00 0.00 0.00 0.20 0.00 99.80