简介
虽然很多人都有针对这个60秒性能分析的翻译,我依然要重写一遍,以加强记忆。
10个命令列表
上述的10个命令基本涵盖了cpu,内存,硬盘,网络以及内核错误等多个方面,能在短时间内快速评估系统以及进程的运行状态。这些命令需要安装sysstat
包。
如果你记不住命令,那么请采用下图的宏观模式来辅助记忆,此图摘自另外一个强人RiboseYim:
1. uptime
uptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
System load averages is the average number of processes that are either in a runnable or uninterruptable state. A process in a runnable state is either using the CPU or waiting to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg waiting for disk. The averages are taken over the three time intervals. Load averages are not normalized for the number of CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time
当前用户数目以及最近1分钟,5分钟以及15分钟的系统平均负载。系统平均负载指的是处于runnable(运行进程或者就绪进程)或者uninterruptable(不可中断的等待进程)状态的平均的进程数目。
$ uptime
23:51:26up21:31, 1user, loadaverage:30.02,26.43,19.02
上面的这个例子表明负载在不断上升,因为最近1分钟的平均负载(30.02)大于最近15分钟的平均负载(19.02)。
2. dmesg | tail
用于给出最近的10条系统消息,有些错误可能会报告出来,例如下面的日子报告了进程18694
出现了OOM错误。
$ dmesg | tail
[1880957.563150] perl invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
[...]
[1880957.563400] Out of memory: Kill process 18694 (perl) score 246 or sacrifice child
[1880957.563408] Killed process 18694 (perl) total-vm:1972392kB, anon-rss:1953348kB, file-r