Sei sulla pagina 1di 3

vmstat(Virtual Memory Statistics) is used to summarize and report information about system process, memory usage, swapping in/out

page statistics, I/O usage and cpu usage of the linux/unix box. When you type vmstat 2 5 (2 stands for every 2 seconds, 5 for 5 times) and return, the first line (count from line #3) the average usage of the system sources since the last boot. And the following 4 lines, each stands for the average usage of the system sources of the interval you specified in your command line. Below are some typical usage and simple explanation: To check the cpu usage of system: 1.Under Sun Solaris: $ vmstat 2 5 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr s6 s9 s1 sd in sy cs us sy id 0 0 0 2855040 381040 76 11 1186 1 1 0 0 0 0 0 16 756 427 219 3 1 96 0 0 0 2160984 201328 0 5 24 0 0 0 0 0 3 0 3 733 72 101 0 0 100 0 0 0 2160984 201328 0 0 0 0 0 0 0 0 0 0 3 719 48 81 0 0 100 0 0 0 2160984 201328 0 0 0 0 0 0 0 0 0 0 0 710 30 63 0 0 100 0 0 0 2160984 201328 0 0 0 0 0 0 0 0 1 0 3 721 41 85 0 0 100 Under linux: $ vmstat 2 5 procs memory swap r b w swpd free buff cache si so 1 0 0 25324 20196 214720 1529664 0 1 0 0 25324 20196 214720 1529664 0 1 0 0 25324 20180 214728 1529672 0 1 0 0 25324 20168 214728 1529672 0 1 0 2 25324 20148 214740 1529680 0 Simple explanation: r(running):This represents the count of running processes(running means these processes has obtain or waiting for the cpu time). In common circumstances, the system will run in bottleneck if this number exceeds the number of cpu number of your system. If your system is busy doing something, the value of 2 times of cpu count is considered normal. But when not, you should take care of that. b(blocked):Processes that are blocked. 0 is the best status. w(swapped):Processes that are swapped out.0 is the best status. pi(Page swap in, under linux, it is called si):pi(si under linux) begins when ram resource is in a shortage. Pages are swapped out to swapping disk from ram(memory). Two much pi operations will slow down the server.

io bi 0 0 0 0 0

system cpu bo in cs us sy 0 0 0 0 1 0 0 30 109 132 3 0 40 107 135 3 0 60 107 154 2 4 86 116 164 4

id 1 31 35 33 30

66 62 65 66

us(User occupied cpu percentage):Percentage of cpu time that serving user tasks. sy(System occupied cpu percentage):Percentage of cpu time that serving system tasks. id(Idle cpu time):Percentage of cpu time that in idle status.If this equals 0 all the time, or if cpu sy is two times of cpu us, then the system comes to the bottleneck of cpu resources. If r(running) is bigger than the mount of cpu, then the system comes to the bottleneck of resources. So, how to find the cpu amount? Under Solaris: $ psrinfo -v|grep Status of virtual processor|wc -l Under linux: $ cat /proc/cpuinfo|grep processor|wc -l How to solve the problem of cpu bottleneck? Here are some methods: First, add more cpu to the machine. Second, shedule the resource-needed batch jobs at the time of your systems unbusy period, for example in the mid-night if your application is web-oriented. Third, adjust the priority level of processes(nice value). So, how to find the memory size of the system? First method, using top command: $ top load averages: 0.89, 0.97, 0.76 16:01:24 60 processes: 58 sleeping, 2 on cpu CPU states: % idle, % user, % kernel, % iowait, % swap Memory: 2048M real, 32M free, 1981M swap in use, 2101M swap free Under Solaris: $ prtconf|grep -i mem Memory size: 2048 Megabytes memory (driver not attached) virtual-memory (driver not attached) Under linux: $ free total Mem:

used free shared buffers 2065204 2036376 28828

cached 0 216248

1535020

-/+ buffers/cache: Swap: 2044056

285108 1780096 25324 2018732

Potrebbero piacerti anche