日期:2014-05-16 浏览次数:20697 次
下面分别列出linux分析、诊断及调优时用到的工具,并分别进行说明,以方便自己和其他同学参考学习,禁止转载。
1、top
top - 02:06:59 up 4 days, 17:14, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 62 total, 1 running, 61 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.2% us, 0.3% sy, 0.0% ni, 97.8% id, 1.7% wa, 0.0% hi, 0.0% si
Mem: 515144k total, 317624k used, 197520k free, 66068k buffers
Swap: 1048120k total, 12k used, 1048108k free, 179632k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13737 root 17 0 1760 896 1540 R 0.7 0.2 0:00.05 top
238 root 5 -10 0 0 0 S 0.3 0.0 0:01.56 reiserfs/0
1 root 16 0 588 240 444 S 0.0 0.0 0:05.70 init
2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
4 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
5 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
6 root 5 -10 0 0 0 S 0.0 0.0 0:00.02 events/0
输出列说明:
PID:Process identification.
USER:Name of the user who owns (and perhaps started) the process.
PRI:Priority of the process. (See 1.1.4, “Process priority and nice level” on page 5 for details.)
SIZE:Amount of memory (code+data+stack) used by the process in kilobytes.
RSS:Amount of physical RAM used, in kilobytes.
SHARE:Amount of memory shared with other processes, in kilobytes.
STAT:State of the process: S=sleeping, R=running, T=stopped or traced,D=interruptible sleep, Z=zombie.
%CPU:Share of the CPU usage (since the last screen update).
%MEM:Share of physical memory.
TIME:Total CPU time used by the process (since it was started).
COMMAND:Command line used to start the task (including parameters).
有用的热键:
t :Displays summary information off and on.
m :Displays memory information off and on.
A :Sorts the display by top consumers of various system resources. Useful for quick identification of performance-hungry tasks on a system.
f :Enters an interactive configuration screen for top. Helpful for setting up top for a specific task.
o :Enables you to interactively select the ordering within top.
r :Issues renice command.
k :Issues kill command.
O or F:enters an interactive configuration screen for processes order.
h:displays help screen.
2、vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 1 0 1742264 112116 1999864 0 0 1 4 3 3 0 0 99 0
0 1 0 1742072 112208 1999772 0 0 0 2536 1258 1146 0 1 75 24
0 1 0 1741880 112260 1999720 0 0 0 2668 1235 1002 0 1 75 24
0 1 0 1741560 112308 1999932 0 0 0 2930 1240 1015 0 1 75 24
1 1 0 1741304 112344 2000416 0 0 0 2980 1238 925 0 1 75 24
0 1 0 1741176 112384 2000636 0 0 0 2968 1233 929 0 1 75 24
0 1 0 1741304 112420 2000600 0 0 0 3024 1247 925 0 1 75 24
输出列说明:
Process (procs) r:The number of processes waiting for runtime
b: The number of processes in uninterruptable sleep
Memory swpd: The amount of virtual memory used (KB)
free: The amount of idle memory (KB)
buff: The amount of memory used as buffers (KB)
cache: The amount of memory used as cache (KB)
Swap si: Amount of memory swapped from the disk (KBps)