Thursday, December 18, 2008

Linux system resource monitor using VMSTAT

Linux resource monitor using VMSTAT-Vmstat reports virtual memory statistics of processes, virtual memory, disk, trap, and CPU activity. Vmstat is useful to correlate memory, processes, and CPU utilization of a system. On multi-processor systems, vmstat averages the number of CPUs into the output.


vmstat interval count
options -- Options are used to get information about specific activity. A complete set of options can be seen by referring to man vmstat on your system.

interval -- This is the time period in seconds between two samples. Too small an interval (< 5 sec) may add command overhead to the output results, and the results may not reflect the true system state.

count -- This is the number of times the data is needed. The first line of vmstat gives the average of data since the time of system reboot and can be ignored. Without the count option, the command produces continuous samples until terminated by ^c. As a common practice, the samples are observed for some time without count argument to get a feel of system state.

Procs
r: The number of processes waiting for run time.
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable. This field is calculated, but Linux never desperation swaps.

Swap
si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).

IO
bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).

System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

CPU
These are percentages of total CPU time.
us: user time
sy: system time
id: idle time

Run for a particular time & Redirect to file
Eg: Run the vmstat for 1 hour


vmstat -n 5 750 > filename.log &

750 --> Number of times at the interval of 5 sec. How --> 5*750/60*60 =~ 1 Hr


Bottleneck Idetification:
1. If the number of processes in the run queue column "r" under procs is consistently greater than the number of CPUs on the system, it will slow down the system because there are more processes than available CPUs.
2. If this number is more than four times the number of available CPUs in the system, then the system is facing a shortage of CPU resources.
3. If the idle time (cpu id) is consistently 0 and the system time (cpu sy) is double the user time (cpu us), the system is facing a shortage of CPU resources

No comments:

Post a Comment