Iostat vmstat Command Detailed

Source: Internet
Author: User
Tags cpu usage disk usage

This article explains the specific usage of vmstat and iostat, and the use of this usage if you diagnose system faults quickly and then optimize the system

Body:

Monitoring memory usage with Vmstat

Vmstat is the abbreviation for Virtual Meomory Statistics (fictitious memory statistics) that monitors virtual memory, processes, and CPU activity on the operating system. It is the overall situation of the system statistics, the disadvantage is that a process can not be in-depth analysis.

The syntax for Vmstat is as follows:


Vmstat [-v] [-n] [delay [count]]


Where the-V indicates that the version information is printed;-n indicates that the header information for the output is displayed only once for periodic cyclic output, delay is the latency between two outputs, and count refers to the number of times that the time interval is calculated. For vmstat output The meaning of each field, you can run the man Vmstat view.

Monitoring I/O subsystem conditions with Iostat

Iostat is an abbreviation for I/O statistics (input/output statistics), and the Iostat tool will monitor the system's disk operation activities. It is characterized by reporting disk activity statistics and also reporting CPU usage. Like Vmstat, Iostat also has a weakness that it cannot analyze a process in depth and only analyze the overall situation of the system.

The syntax for Iostat is as follows:


Iostat [-C |-d] [-K] [-t] [-v] [x [Device]] [interval [count]]


Where-C to report CPU usage;-D to report disk usage;-K means to display data by kilobytes byte per second;-T for print reporting time;-V to print out version information and usage;-X device Specify the name of the device to be counted, default to all devices Interval refers to the time at which each statistical interval is counted, and count refers to the number of times it is counted at this time interval.

The Iostat general output format is as follows:

Linux 2.4.18-18SMP (builder.linux.com) March 07, 2003

AVG-CPU:%user%nice%sys%idle
4.81 0.01 1.03 94.15

Device:tps blk_read/s blk_wrtn/s Blk_read Blk_wrtn
dev3-0 30.31 1117.68 846.52 16104536 12197374
Dev3-1 7.06 229.61 40.40 3308486 582080
For the meanings of the fields in the output, the Iostat help is explained in detail.

Vmstat command reports virtual memory statistics and CPU load: page scheduling, swapping, task switching, CPU utilization. The syntax for the command is:
Vmstat [-ciss] [D1 D2 d3 d4] [interval [count]]
When the option is not available, Vmstat displays a curve indicating the information that has been active since the system started. If you specify interval (time interval), the next line is to repeat the last interval period activity until the user interrupts the command execution. When a counter is provided, statistics are displayed by time count.
If you specify a disk name (such as D1,D2, and so on). ), these disks are prioritized. Typically, the first 4 disk devices on the system are displayed because only four devices can be displayed on a single line, which allows the performance analyst to modify the default display options. (* Disk names are usually named with Id,sd,xd, or xy (depending on the type and i/0 interface) plus a number, such as Id0,sd2,xd1, and so on. ), the Vmstat command displays several field information:

Procs the number of processes in the following three states of the report:
r--is waiting to run in the run queue
b--is blocked by resources (i/0, page scheduling, etc.)
w--can be run but swapped out
Memory reports virtual memory and stored information:
swap--the number of currently available swap spaces in kilobytes
free--page Free table size in thousand-byte units
Page reports information about the number of pages scheduled activity per second:
re-from free Table Recycle page
mf--minor error; address space or hardware address translation error
pi--number of kilobytes in page
Po-Kilobytes of page out
Number of kilobytes freed by fr-
de--an acceptable short memory shortage in kilobytes
sr--pages are scanned by the clock algorithm
Disk can report the number of disks I/O per second for four disks

Faults reports the rate of system software outages and hardware outages per second
in-device interrupt, not including system clock interrupt
sy-system Call
CS-CPU Task (context) Exchange
cpu--the percentage of CPU failure times, which is the average for all processors on multiprocessor systems:
us-User Time
sy--system Time
id--Idle Time

The Vmstat command has four optional flags to use. If the machine has a virtual address cache-C flag, change the output report cache refresh statistics. Reports include the total amount of each cache flush since the system started. Six cache types are user, context, area, segment, page, partial page.
The-I flag changes the output to the number of report interrupts. If the device name, such as D1,D2, is given, the monitoring will be performed at the device level, (* note, see Chapter 12th for information on opening device-level monitoring.) and reports statistics for each given device.

Modify the normal report to display information about the exchange rather than the page scheduling activity. This option changes the two fields displayed: Si (swapped in) and so (swapped out) replaces the RE and MF fields.

It is worth noting that the interval and count options are illegal for the-I or the-s option.


Vmstat parameter Detailed

Procs:

r--> number of processes waiting in the run queue
B--> the number of processes waiting for IO
W--> can enter a process that runs the queue but is replaced

Memoy

Swap--> currently available swap memory (k)
free--> free memory (k)


Pages

re--"Recycled pages
mf--"Not a serious error page
pi--"Number of pages entered (k)
po--the number of pages (k)
fr--Number of free pages (k)
de--the number of misses in the page read in advance
sr--pages scanned by the clock algorithm

Disk operation is displayed per second. s for SCSI disk, 0 for disk number

Fault shows the number of interrupts per second
in--"Equipment interrupted
sy--"System interrupted
cy--"CPU Switching

CPU indicates the CPU usage state

cs--the time used by the user process
sy--the time used by the system process
id--"CPU Idle Time


FIELD Descriptions
Procs
R:the number of processes waiting for run time.
B:the number of processes in uninterruptable.
W:the number of processes swapped out but otherwise runnable.

Thisfield is calculated, but Linux never desperation swaps.

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).

Swap
Si:amount of memory swapped in from disk (KB/S). Page import of virtual memory (import RAM from swap disk)
So:amount of memory swapped to disk (KB/S). The page export of virtual memory.
(from RAM to swap DISK)

Io
Bi:blocks sent to a block device (BLOCKS/S). Write
Bo:blocks received from the Block device (BLOCKS/S). Write out

System
In:the number of interrupts per second, including the clock.
Cs:the Number of context switches/second.
: CPU
These are percentages of total CPU time.
Us:user time
Sy:system time
Id:idle time


If R is often greater than 4 and the ID is often less than 40, the CPU load is heavy.
If the Pi,po is not equal to 0 for a long time, it indicates insufficient memory.
If disk is often not equal to 0, and the queue in B is greater than 3, the IO performance is not good.


See Server by Vmstat


Note: Because Statspack does not have all the information needed to fully analyze performance issues, it needs to extend its collection server statistics.

Vmstat Introduction

Collecting server information through Statspack, mainly by collecting vmstat information to show the server status. The Vmstat tool is the most common UNIX monitoring tool that can show the status values of servers at a given time interval.

The use of general vmstat Tools is done with two numeric parameters, the first parameter is the number of time intervals sampled, the unit is seconds, and the second parameter is the number of times the sample is sampled. Such as:
[Oracle@brucelau oracle]$ Vmstat 1 2
Procs Memory Swap IO system CPU
R b w swpd free buff cache si and bi bo in CS us sy ID
1 0 0 0 271844 186052 255852 0 0 2 6 102 10 0-0 100
0 0 0 0 271844 186052 255852 0 0 0 0 104 11 0-0 100

(Note: The system is almost idle, and different operating systems vmstat output content)

For now, the metrics for server monitoring are:

R (Run queue)
Pi (page import)
US (user CPU)
Sy (System CPU)
ID (Idle)

Identify CPU bottlenecks through Vmstat

R (Run queue) shows the number of tasks that are executing and waiting for CPU resources. When this value exceeds the number of CPUs, there is a CPU bottleneck.
Commands to get the number of CPUs (Linux environment):
Cat/proc/cpuinfo|grep processor|wc–l
When the R value exceeds the number of CPUs, there will be CPU bottlenecks, the solution is generally several:
1. The simplest is to increase the number of CPUs
2. Through the adjustment of task execution time, such as large tasks to be carried out in the context of the system is not busy to carry out, the incoming balance system tasks
3. Adjust the priority of an existing task

Identify CPU full load through Vmstat

The first thing to declare is that the CPU metric in Vmstat is a percentage. When the value of Us+sy is close to 100, it means that the CPU is approaching full load. Note, however, that the CPU's full workload does not explain what Unix always tries to get the CPU as busy as possible, maximizing the throughput of the task. The only thing that can determine the CPU bottleneck is the value of R (Run queue).

Identifying Ram bottlenecks through Vmstat

The database server has only limited RAM, and memory contention is a common problem for Oracle.
First look at the amount of RAM, which commands the following (Linux environment):
[Root@brucelau Root] #free
Total used free shared buffers Cached
mem:1027348 873312 154036 185736 187496 293964
-/+ buffers/cache:391852 635496
swap:2096440 0 2096440

Of course, you can use other commands such as top to display RAM.

When the memory requirements are greater than the amount of RAM, the server starts the virtual memory mechanism, through virtual memory, you can move the RAM segment to the special disk segment of swap disk, this will appear the Virtual memory page export and page import phenomenon, page export does not explain the ram bottleneck, Virtual Memory systems often page export of memory segments, but the page import operation indicates that the server needs more memory, and page import needs to replicate the memory segment from swap disk back to RAM, causing the server to slow down.

There are several solutions:
1. The simplest, increased RAM
2. Change the small SGA so that the ram demand is reduced
3. Reduce RAM requirements (e.g., reduce PGA)

We have a basic understanding of vmstat work, the following is statspack through Vmstat statistics collection server performance data.

Statspack collects server information through Vmstat
First, create a table under the Perfstat user that stores server information: such as
Build table:
CREATE TABLE Stats$vmstat
(
Start_date date,--system time
Duration date,--time interval
_name VARCHAR2 (20), server name
Runque_waits number,--run queue data
Page_in number,--page import data
Page_out number,--page export data
USER_CPU number,--User CPU data
SYSTEM_CPU number,--system CPU data
IDLE_CPU number,--free CPU data
WAIT_CPU number– waits for CPU data (only AIX exists)
)
Tablespace Perfstat;
Then, the Unix/linux shell becomes, using the results of the vmstat to obtain the appropriate server information, and stored in the table.

Mpstat

The

  Vmstat command explains in detail kthr--The status of the kernel process
--r The number of processes in the run queue, under a steady workload, less than 5
--b the number of processes in the wait queue ( Wait for I/O), usually close to 0.
memory--virtual and real memory usage
--AVM The active virtual page, the page space number assigned to the work segment in the process run.
--fre the number of idle lists. Generally not less than 120, When the fre is less than 120, the system starts the automatic kill process to release
  page--page activity Information
--re page I/O list
--pi page entered from page (generally less than 5)
--po output to page
-- FR Idle pages (number of pages that can be replaced)
--sr number of pages searched by page replacement algorithm
--cy the clock frequency of the page replacement algorithm
faults--the number of traps and interrupts in the sampling interval
--in device interrupts
--sy system call interrupts
--cs of swap interrupts before and after kernel processes
CPU--CPU usage
--us user process time
--sy system process time
--id CPU idle time
--wa wait I/O time
General Us+sy in single No more than 90 in the user system, not more than 80 in a multiuser system.
WA time is generally less than.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.