We have moved to www.dataGenX.net, Keep Learning with us.

Wednesday, July 11, 2012

Vmstat : Monitoring Virtual Memory


Virtual Memory :
Using a disk as an extension of RAM so that the effective size of usable memory grows correspondingly



How Virtual Memory Works

Physical memory—the actual RAM installed—is a finite resource on any system. As we know All processes use memory, but each process doesn't need all its allocated memory all the time. Taking advantage of this fact, the kernel frees up physical memory by writing some or all of a process' memory to disk until it's needed again.
When pages are written to disk, the event is called a page-out, and when pages are returned to physical memory, the event is called a page-in. A page fault occurs when the kernel needs a page, finds it doesn't exist in physical memory because it has been paged-out, and re-reads it in from disk.
Page ins are usual, so no need to worry about these, but Page out have. When Kernel got to know that we are running low on Physical memory then it start searching defined virtual space in Hard Disk and write the processes in there. Sometimes Kernel is quite busy with these task, fetching n inserting pages, and unable to give more resource to process running in front.

For tracking the memory status we use “VMSTAT” command.
By default vmstat displays the memory information in kb


A) If we simply execute the “vmstat” command on the terminal


$ vmstat




This will give the current status of Virtual Memory and quit.
·         kthr – r: Total number of processes waiting to run
·         kthr – b: Total number of busy processes
·         Memory – avm: Active virtual pages
·         Memory – free: Free virtual memory
·         Page – re: Pager input/output list
·         Page – pi: Pages paged in from paging space
·         Page – po: Pages paged out to paging space
·         Page – fr: Pages freed (page replacement)
·         Page – sr: Pages scanned by page-replacement algorithm
·         Page – cy: Clock cycles by page-replacement algorithm
·         Faults – in : Device interrupts
·         Faults – sy : System calls
·         Faults – cs : Kernel thread context switches
·         Cpu – us : User time
·         Cpu – sy : System time
·         Cpu – id : CPU idle time
·         Cpu – wa : CPU idle time during which the system had I/O or disk request
·         Cpu – pc : Number of physical processors consumed
·         Cpu – ec : The percentage of entitled capacity consumed


B) To get the Virtual memory status in every 3 seconds


$ vmstat 3




This command will generate the result in every 3 sec for infinity times. For stopping the output we can use Ctrl-C



C) To get the Virtual memory status in every 2 seconds with 10 update only


$ vmstat 2 10





D) Display number of forks since last boot

$ vmstat –f





E) Displays the number of interrupts taken by each device since system startup


$ vmstat –i







F) Display the Sum of event in readable format

$ vmstat –s
display the sum of events, which contains an absolute count of paging events since system startup.






G) Display the various statistics


$ vmstat –v






H) To increase the width of output  


$ vmstat –w
The default output without increasing the width





For more detailed information about “VMSTAT” go to this link
VMSTAT





njoy the simplicity.......
Atul Singh

No comments :

Post a Comment