Vmstat and Iostat detailed

Source: Internet
Author: User
Tags switches cpu usage disk usage
With high stability and reliability, Linux has good scalability and scalability, and can be adapted to different applications and hardware environments to optimize the best performance to meet current application needs. Therefore, it is very important for enterprises to understand the system performance analysis tools when they are maintaining Linux systems and tuning systems.

Linux has a lot of system performance analysis tools, more common there are top, free, PS, time, Timex, uptime and so on. Some of the more important performance analysis tools Vmstat, Iostat, and SAR are described below.

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

Bo:blocks received from the Block device (BLOCKS/S).

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. (This article Environment Redhat Linux7.) 2)

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

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

About Shell programming, may have been beyond the content of this article, and honestly, I do not have shell programming experience, I hope that brother can complete the shell programming content, and please mail me to share, thank you first.


Report:

Help manual for Vmstat on Linux: (Results of man Vmstat)


VMSTAT (8) Linux Administrator ' s Manual VMSTAT (8)

NAME

Vmstat-report Virtual Memory Statistics


Synopsis

Vmstat [-n] [delay [count]]

VMSTAT[-V]

DESCRIPTION

Vmstat reports information about processes, memory, paging, block IO, traps, and CPU activity.

The produced gives averages since the last reboot. Additional reports give information on a sam-

Pling period of length delay. The process and memory reports are instantaneous in either case.

Options

The-n switch causes the header to is displayed only once rather than.

Delay is the delay between updates in seconds. IF no delay is specified, only one the be printed with the

Average values since boot.

The count is the number of updates. If no count is specified and delay are defined, count defaults to infinity.

THE-V switch results in displaying version information.

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

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

So:amount of memory swapped to disk (KB/S).


Io

Bi:blocks sent to a block device (BLOCKS/S).

Bo:blocks received from the Block device (BLOCKS/S).


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


NOTES

Vmstat does not require special permissions.

These reports are intended to help identify system bottlenecks. Linux Vmstat does not count itself as a running process.

All Linux blocks are currently 1k, except for CD-ROM blocks which are 2k.


FILES

/proc/meminfo

/proc/stat

/proc/*/stat

ALSO

PS (1), Top (1), free (1)

BUGS

Does not tabulate the "block IO" Per Device or count the number of system calls.

AUTHOR

Written by Henry Ware <al172@yfn.ysu.edu>.

Throatwobbler Ginkgo Labs July 1994 VMSTAT (8)

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.