vmstat的應用詳解
Virtual Memory Statistics ( vmstat ) vmstat 是報告關於程式,虛擬記憶體,磁碟,CPU活動的一個統計報告.
在一個多CPU系統中,vmstat統計所有個數的CPU的平均輸出.為每個程式進行統計.沒有引數時,vmstat顯示每一行是自從系統啟動以後的虛擬記憶體的活動情況.(注:vmstat輸出的第一行對於實施統計沒有意義)
用法:
基本的用法是vmstat
option: 指定我們所需要的輸出選項比如: paging -p , cache -c ,.interrupt -i 等等(還有一個比較有用的是S),更加具體的vmstat的引數情況可以參照man手冊和系統管理員手冊的相應說明.
如果沒有指定引數,輸出的資訊是關於process , memory , paging , disk ,interrupts & cpu的顯示.
interval 是在兩個輸出結果輸出的時候給予的間隔時間.. vmstat 4 是給予4秒的間隔.
count 是你需要的輸出的資料量.ivmstat 4 5 是間隔4秒輸出5次資料.
下面是關於一些引數的描述:
procs
r in run queue
b blocked for resources I/O, paging etc.
w swapped
memory (in Kbytes)
swap - amount of swap space currently available
free - size of the free list
page ( in units per second).
re page reclaims - see -S option for how this field is modified.
mf minor faults - see -S option for how this field is modified.
pi kilobytes paged in
po kilobytes paged out
fr kilobytes freed
de anticipated short-term memory shortfall (Kbytes)
sr pages scanned by clock algorithm
disk ( operations per second )
There are slots for up to four disks, labeled with a single letter and number.
The letter indicates the type of disk (s = SCSI, i = IPI, etc) . The number is
the logical unit number.
faults
in (non clock) device interrupts
sy system calls
cs CPU context switches
cpu - breakdown of percentage usage of CPU time. On multiprocessors this is an average across all processors.
us user time
sy system time
id idle time
CPU問題現象:
1.) 如果在processes中執行的序列(process r)是連續的大於在系統中的CPU的個數表示系統現在執行比較慢,有多數的程式等待CPU.
2.) 如果r的輸出數大於系統中可用CPU個數的4倍的話,則系統面臨著CPU短缺的問題,或者是CPU的速率過低,系統中有多數的程式在等待CPU,造成系統中程式執行過慢.
3.) 如果空閒時間(cpu id)持續為0並且系統時間(cpu sy)是使用者時間的兩倍(cpu us) 系統則面臨著CPU資源的短缺.
解決辦法:
當發生以上問題的時候請先調整應用程式對CPU的佔用情況.使得應用程式能夠更有效的使用CPU.同時可以考慮增加更多的CPU. 關於CPU的使用情況還可以結合mpstat, ps aux top prstat –a等等一些相應的命令來綜合考慮關於具體的CPU的使用情況,和那些程式在佔用大量的CPU時間.一般情況下,應用程式的問題會比較大一些.比如一些SQL語句不合理等等都會造成這樣的現象.
記憶體問題現象:
記憶體的瓶頸是由scan rate (sr)來決定的.scan rate是透過每秒的始終演算法來進行頁掃描的.如果scan rate(sr)連續的大於每秒200頁則表示可能存在記憶體缺陷.同樣的如果page項中的pi和po這兩欄表示每秒頁面的調入的頁數和每秒調出的頁數.如果該值經常為非零值,也有可能存在記憶體的瓶頸,當然,如果個別的時候不為0的話,屬於正常的頁面排程這個是虛擬記憶體的主要原理.
解決辦法:
1.調節applications & servers使得對記憶體和cache的使用更加有效.
2.增加系統的記憶體.
3. Implement priority paging in s in pre solaris 8 versions by adding line "set priority paging=1" in
/etc/system. Remove this line if upgrading from Solaris 7 to 8 & retaining old /etc/system file.
關於記憶體的使用情況還可以結ps aux top prstat –a等等一些相應的命令來綜合考慮關於具體的記憶體的使用情況,和那些程式在佔用大量的記憶體.一般情況下,如果記憶體的佔用率比較高,但是,CPU的佔用很低的時候,可以考慮是有很多的應用程式佔用了記憶體沒有釋放,但是,並沒有佔用CPU時間,可以考慮應用程式,對於未佔用CPU時間和一些後臺的程式,釋放記憶體的佔用.
寫的不對的地方歡迎朋友幫忙指出。謝謝,並且幫助補充。謝謝!!!
Solaris Performance Monitoring & Tuning - iostat , vmstat & netstat Introduction to iostat , vmstat and netstat This document is primarily written with reference to solaris performance monitoring and tuning but these tools are available in other unix variants also with slight syntax difference. iostat , vmstat and netstat are three most commonly used tools for performance monitoring . These comes built in with the operating system and are easy to use .iostat stands for input output statistics and reports statistics for i/o devices such as disk drives . vmstat gives the statistics for virtual Memory and netstat gives the network statstics . Following paragraphs describes these tools and their usage for performance monitoring and if you need more information there are some very good solaris performance monitoring books available at . Table of content : iostat reports terminal and disk I/O activity and CPU utilization. The first line of output is for the time period since boot & each subsequent line is for the prior interval . Kernel maintains a number of counters to keep track of the values. iostat's activity class options default to tdc (terminal, disk, and CPU). If any other option/s are specified, this default is completely overridden i.e. iostat -d will report only statistics about the disks. Basic synctax is iostat option - let you specify the device for which information is needed like disk , cpu or terminal. (-d , -c , -t or -tdc ) . x options gives the extended statistics . interval - is time period in seconds between two samples . iostat 4 will give data at each 4 seconds interval. count - is the number of times the data is needed . iostat 4 5 will give data at 4 seconds interval 5 times | |
--> |
$ iostat -xtc 5 2 extended disk statistics tty cpu disk r/s w/s Kr/s Kw/s wait actv svc_t %w %b tin tout us sy wt id sd0 2.6 3.0 20.7 22.7 0.1 0.2 59.2 6 19 0 84 3 85 11 0 sd1 4.2 1.0 33.5 8.0 0.0 0.2 47.2 2 23 sd2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 sd3 10.2 1.6 51.4 12.8 0.1 0.3 31.2 3 31 The fields have the following meanings: disk name of the disk r/s reads per second w/s writes per second Kr/s kilobytes read per second Kw/s kilobytes written per second wait average number of transactions waiting for service (Q length) actv average number of transactions actively being serviced (removed from the queue but not yet completed) %w percent of time there are transactions waiting for service (queue non-empty) %b percent of time the disk is busy (transactions in progress) |
The values to look from the iostat output are:
- Reads/writes per second (r/s , w/s)
- Percentage busy (
%b
) - Service time (
svc_t
)
1.10.4 Use vmstat
The
vmstat utility is the most common Unix monitoring utility, and it is found in the majority of Unix dialects (vmstat is called osview in IRIX). The vmstat utility displays various server values at a given time interval. The first numeric argument to vmstat represents the time interval expressed in seconds. In the example that follows, I execute vmstat 3 and get a line of output every three seconds:>
vmstat 3kthr memory cpu
---- ... --------------- ... --------------
r b ... fre re pi sr ... cs us sy id wa
0 0 ... 207 0 1 0 ... 142 18 4 75 4
0 0 ... 187 0 4 0 ... 70 2 1 91 6
0 0 ... 184 0 0 0 ... 99 5 2 89 4
0 0 ... 165 0 0 0 ... 98 1 8 52 40
0 0 ... 150 0 3 0 ... 136 4 2 87 6
0 0 ... 141 0 1 0 ... 192 5 0 91 4
You can exit
The critical
vmstat at any time by pressing Ctrl-C. vmstat values that you need to know about are as follows:r
The run queue. When this value exceeds the number of CPUs, the server is experiencing a CPU bottleneck. (You can get the number of CPUs by entering
lsdev -C|grep Process|wc -l.)pi
The page-in count. Non-zero values typically indicate that the server is short on memory and that RAM is being written to the swap disk. However, non-zero values can also occur when numerous programs are accessing memory for the first time. To find out which is the case, check the scan rate (
sr) column. If both the page-in count and the scan rate are non-zero, then you are short on RAM.sr
The scan rate. If you see the scan rate rising steadily, you know that the paging daemon is busy allocating memory pages.
For AIX and HP-UX,
vmstat also provides the following CPU values. These values are expressed as percentages and will sum to 100:us
User CPU percentage
sy
System CPU percentage
id
Idle CPU percentage
wa
When the sum of user and system CPU percentages (
When wait CPU percentages (the
1.10.2 Use sar
The
Just like
There are three major flags that you can use with
sar utility (System Activity Reporter) is quite popular in SVR4 environments such as HP-UX and Solaris. It is also becoming widely available for AIX. top, sar gives detailed information about Oracle tasks from the Unix level. You will be able to see the overall consumption of CPU, disk, memory, and Journal File System ( JFS) buffer usage. sar :sar -u
Shows CPU activity
sar -w
Shows swapping activity
sar -b
Shows buffer activity
1.10.2.1 sar -u (CPU report)
The
1.10.2.2 sar -w (memory switching and swapping activity)
The
The following example shows the swapping activity report that you get from
sar -w command is especially useful if you suspect that your database server is experiencing a memory shortage. When an Oracle server runs short of real memory, segments of RAM are swapped out to a swap disk. Such page-out operations happen frequently, but a page-in indicates that the Oracle server is exceeding the amount of RAM. The usual remedies for swapping are to reduce the size of the SGA and/or to buy more RAM for the database server. sar :ROOT>
sar -w 5 5HP-UX corp-hp1 B.11.00 U 9000/800 08/09/00
19:37:57 swpin/s bswin/s swpot/s bswot/s pswch/s
19:38:02 0.00 0.0 0.00 0.0 222
19:38:07 0.00 0.0 0.00 0.0 314
19:38:12 0.00 0.0 0.00 0.0 280
19:38:17 0.00 0.0 0.00 0.0 295
19:38:22 0.00 0.0 0.00 0.0 359
Average 0.00 0.0 0.00 0.0 294
The columns have the following meanings:
swpin/s
Number of process swap-ins per second
swpot/s
Number of process swap-outs per second
bswin/s
Number of 512-byte swap-ins per second
bswot/s
Number of 512-byte swap-outs per second
pswch/s
Number of process context switches per second
sar -u command is very useful for seeing the overall CPU consumption over time. CPU time can be allocated into the following four buckets: user mode, system mode, waiting on I/O, and idle. In the example that follows, I execute sar -u to see the state of the CPU:Wait CPU percentage
us + sy) approaches 100, then the CPUs are busy, but not necessarily overloaded. The run queue value can indicate a CPU overload, but only when the run queue exceeds the number of CPUs on the server. wa values) exceed 20, then 20% or more of the processing time is waiting for a resource, usually I/O. It is common to see high wait CPU percentages during backups and exports, but they can also indicate an I/O bottleneck.來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14377/viewspace-1022180/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- vmstat詳解
- vmstat命令詳解
- vmstat 引數詳解
- AIX vmstat命令詳解AI
- vmstat linux命令詳解Linux
- stat 命令家族(1)- 詳解 vmstat
- meminfo vmstat procrank top等詳解
- vmstat與iostat詳解(zt)iOS
- 【轉】Linux中Vmstat命令列出的屬性詳解Linux命令列
- Vmstat 命令詳細介紹
- Word域的應用和詳解
- Linux作業系統Vmstat命令列出的屬性詳解Linux作業系統命令列
- Go 語言 sync 包的應用詳解Go
- Redis詳解以及Redis的應用場景Redis
- Hive學習之三 《Hive的表的詳解和應用案例詳解》Hive
- 從原理到應用,Elasticsearch詳解Elasticsearch
- 歸併排序詳解及應用排序
- 乾貨分享|Bitset 應用詳解
- 並查集詳解與應用並查集
- Android中SQLite應用詳解AndroidSQLite
- vmstat的使用
- 詳解 Flink 實時應用的確定性
- 詳解javascript拖拽(二)拖拽的應用及示例JavaScript
- iOS開發中的Scroll View應用詳解iOSView
- Android PathMeasure詳解和應用Android
- Go通道機制與應用詳解Go
- 構建流式應用—RxJS詳解JS
- quartz (從原理到應用)詳解篇quartz
- PHP 中 Trait 詳解及其應用PHPAI
- kafka詳解三:開發Kafka應用Kafka
- 各種UNIX平臺下vmstat與iostat輸出結果詳解iOS
- 詳解 Serverless 架構的 6 大應用場景Server架構
- Docker從瞭解到部署應用的詳細教程Docker
- 詳解Python中sys模組的功能與應用Python
- FIBOS DAPP 應用場景詳解APP
- Apple App Clip(蘋果「輕應用」)詳解APP蘋果
- Zookeeper基礎原理&應用場景詳解
- Oracle minus用法詳解及應用例項Oracle