天天看點

SAR系統性能檢測工具

 /**

* sar man手冊簡譯, 歡迎大家補充、指正

* Author: cnscn

* Time : 2006-10-17 09:10

*

*/

sar --- 收集、報告或儲存系統活動資訊 Collect, report, or save system activity information

Options:

-A 列出儲存的當天的所有活動的檔案内容, 等同于-bBcdqrRuvwWy -I SUM -n FULL -P ALL

-b 報告I/O和傳送速率統計。這個參數僅用于2.5及以後核心。可顯示以下字段

tps 每秒從實體磁盤I/O的次數。多個邏輯請求會被合并為一個I/O磁盤請求。一次傳輸的大小是不确定的

rtps 每秒的讀請求數

wtps 每秒的寫請求數

bread/s 每秒讀磁盤的資料塊數(in blocks 1 block = 512B, 2.4以後核心)

bwrtn/s 每秒寫磁盤的資料塊數(in blocks 1 block = 512B, 2.4以後核心)

-B 顯示核心頁統計。 可顯示如下字段

pgpgin/s

pgpgout/s

fault/s

majflt/s

-c 顯示程序建立活動, 顯示如下字段

proc/s 每秒程序建立數

-d m n 報告每個塊裝置的活動情況(2.4及以後核心)

m 每m秒采樣一次

n 共采樣n次

sar -d 30 5

Average: DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util

dev8-0 2.39 16.37 35.99 21.88 0.00 0.85 0.66 0.16

tps 顯示指定裝置的每秒I/O流量,多個邏輯請求可以合并為一個實體請求,流量為不确定大小

rd_sec/s 從裝置讀取的扇區數,(1扇區=512B)

wr_sec/s 寫入裝置的扇區數

avgrq-sz 流出裝置的扇區數

avgqu-sz 流出裝置的平均隊列長度

await 從裝置流出的平均I/O請時間,包括請求在隊列和服務時的時間

svctm 平均I/O請求的服務時間

%util I/O請求的CPU時間百分比,當數字接近100%時,裝置出現飽和

-H

-h

-i interval 選取盡可能接近interval所辨別的數量的記錄數 (Select data records at seconds as close as possible to the number specified by the interval parameter)

-q 報告隊列長度和平均負載,可列出下列字段

runq-sz 執行中的隊列長度(等待運作的程序數)

plist-sz 程序清單中的程序數

ldavg-1 最後一分鐘的系統負載

ldavg-5 最後5分鐘的系統負載

ldavg-15 最後15?種擁南低掣涸?

-r 報告memory和swap使用統計,可列出如下字段

kbmemfree 可用的記憶體數(kB)

kbmemused 應用中的記憶體數,但不包括核心使用的記憶體(kB)

%memused 記憶體的使用百分比

kbcached 核心用于cache的記憶體數(kB)

kbswpfree

kbswpused

%swpused

kbswpcad 用于cache的swap記憶體數(kB)

-R 報告記憶體活動,可列出如下字段

frmpg/s 每秒空閑的記憶體頁數,負值表示系統已經配置設定了的記憶體頁數。注意:依據機器體系的不同,記憶體頁的大小有4kB或8kB

bufpg/s 每秒系統用于buffers的附加的記憶體頁數。負值表示較少的頁數用于系統buffers

campg/s 每秒系統用于cached的附加的記憶體頁數。負值表示較少的頁數用于系統cached

-t

-u 列出cpu的使用情況,可列出下列字段

%user 使用者層

%nice   使用者層

%system  系統層

%iowait  系統有外部磁盤I/O請求時的cpu(s)的空閑時間百分不(Percentage of %time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request)

%idle 系統沒有外部磁盤I/O請求時的cpu(s)的空閑時間百分不(Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request)

-v 報告檔案或其它核心表的inode的狀态,可列出如下字段

dentunusd Number of unused cache entries in the directory cache.

file-sz 已經使用了的檔案句柄數 Number of used file handles

inode-sz Number of allocated disk quota entries.

super-sz 核心已經配置設定了的超級塊的句柄 Number of super block handlers allocated by the kernel

%super-sz Percentage of allocated super block handlers with regard to the maximum number of super block handlers that Linux can allocate.

dquot-sz 已經配置設定了的磁盤限額入口數 Number of allocated disk quota entries.

%dquot-sz Percentage of allocated disk quota entries with regard to the maximum number of cached disk quota entries that can be allocated.

rtsig-sz 隊列中RT信号數 Number of queued RT signals.

%rtsig-sz Percentage of queued RT signals with regard to the maximum number of RT signals that can be queued.

-V 列出版本号和用法

-w 報告系統交換活動,列出如下字段

cswch/s 系統每秒交換活動的次數 Total number of context switches per second

-W 報告swapping活動資訊,可列出如下字段

pswpin/s 每秒系統帶來的交換頁數 Total number of swap pages the system brought in per second.

pswpout/s 系統每秒帶出、拿出的交換頁數

-y

-n {DEV|EDEV|SOCK|FULL}

報告網絡活動統計

DEV 指定列出所有網絡裝置的活動統計,可列出如下字段

IFACE 網絡接口卡裝置名,如eth0

rxpck/s 每秒收到的包數

txpck/s 每秒傳輸的包數

rxbyt/s 每秒收到的資料位元組數

txbyt/s 每秒傳輸的資料位元組數

rxcmp/s 每秒收到的壓縮包數

txcmp/s 每秒傳輸的壓縮包數

rxmcst/s 每秒收到的多點傳播包數

EDEV 指定列出所有網裝置失敗包的情況,可列出如下字段

IFACE 網絡接口卡裝置名

rxerr/s 每秒收到的總的失敗包數

txerr/s 每秒鐘傳輸時的錯誤包數

coll/s 每秒鐘傳輸時的沖突包數

rxdrop/s 每秒鐘收到的包中由于Linux空間缺乏而丢棄的包數

txdrop/s 每秒鐘傳輸過程中由于Linux空間缺乏而丢棄的包數

txcarr/s 每秒鐘傳輸過程中的carrier-errors的數目

rxfram/s 每秒鐘收到的幀序列錯誤數

rxfifo/s 每秒鐘FIFO泛濫錯誤包數

txfifo/s 每秒鐘傳輸時FIFO泛濫的錯誤包數

NFS 列出NFS用戶端活動報告。 列出如下字段

call/s 每秒成功的RPC請求數

retrans/s (由于server逾時)每秒需重新傳輸的RPC請求數

read/s 每秒成功的RPC的read請求數

write/s 每秒成功的RPC的write請求數

access/s 每秒成功的RPC的access請求數

getatt/s 每秒成功的RPC的getattr請求數

NFSD 列出NFS服務端活動報告。列出如下字段

totsck 總的socktes數

tcpsck 目前應用中的tcp sockets數

udpsck 目前應用中的udp sockets數

rawsck 目前應用中的RAW sockets數

ip-frag 目前應用中的IP幀數

FULL 等于指定-n選項的所有參數

-x {pid|SELF|ALL}

-X {pid|SELF|ALL}

-I {irq|SUM|ALL|XALL}

報告中斷統計資料。

irq 是中斷号,指定多個-I irq參數可以觀看到多個相關中斷的情況

SUM 指定顯示每秒中接收到的所有中斷情況

ALL 指定顯示所有中斷的前16個中斷情況

XALL 指定顯示所有中斷包括潛在的APIC中斷源

-P {cpu|ALL}

如果預設-P則報告系統内的所有CPU的統計。如果參數為ALL,則報告每一個CPU和所有CPU的統計資料

[root@localhost ~]# sar -P 0

Linux 2.6.17-1.2187_FC5smp (localhost.localdomain) 2006年10月17日

08時30分01秒 CPU %user %nice %system %iowait %idle

08時40分01秒 0 6.24 0.00 0.64 0.02 93.10

[root@localhost ~]# sar -P 1

Linux 2.6.17-1.2187_FC5smp (localhost.localdomain) 2006年10月17日

08時30分01秒 CPU %user %nice %system %iowait %idle

08時40分01秒 1 7.66 0.00 0.60 0.03 91.71

-o [filename]

把報告輸出到檔案,否則顯示到螢幕. 如果忽略filename,那麼系統将把輸出添加到/var/log/sa/sadd定時生成檔案内(dd代表目前日期)

-f [filename]

從filename中提取預先儲存在檔案内的記錄,并顯示到螢幕上. 預設filename則從/var/log/sa/sadd内提取

-s [hh:mm:ss]

設定報告的開始時間, Set the starting time of the data, causing the sar command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00. Hours must be given in 24-hour format. This option can be used only when data are read from a file (option -f )

-e [hh:mm:ss]

設定報告的結束時間, The default ending time is 18:00:00.This option can be used only when data are read from or written to a file (options -f or -o )

[interval] 選擇記錄的時間間隔(秒)

[count] <預設為1>

sar 向标準輸出列出選擇的活動的累積數量。在多帳戶系?襯冢?ǜ嬉?ount(數量)和interval(時間間隔)參數,以指定秒數為時間間隔的指定的次數資訊.

如果interval參數指定為0,則sar顯示系統啟動以來的平均時間統計。

如果count參數指定為0,則報告将不連續不斷的進行。

如果不指定參數,則僅顯示CPU的活動,如果CPU使用率接近100% (user + nice + system), 則顯示出CPU局限

[root@localhost ~]# sar

08時26分00秒 LINUX RESTART

08時30分02秒 CPU %user %nice %system %iowait %idle

08時40分01秒 all 6.07 0.00 33.86 7.94 52.13

08時50分01秒 all 2.26 0.00 28.32 0.77 68.66

09時00分01秒 all 0.44 0.00 26.75 0.29 72.52

09時10分01秒 all 0.97 0.00 26.87 0.05 72.12

09時20分01秒 all 1.39 0.00 27.13 0.06 71.43

Average: all 2.22 0.00 28.58 1.82 67.38

如果需要多個樣本和報告,那麼可以如下所做

sar -o data.file interval count >/dev/null 2>&1 &

[root@localhost ~]# sar -u 2 5 報告CPU的使用情況,每2秒鐘一次共輸出5行

09時01分53秒 CPU %user %nice %system %iowait %idle

09時01分55秒 all 36.41 0.00 2.49 47.38 13.72

09時01分57秒 all 38.40 0.00 18.20 36.91 6.48

09時01分59秒 all 32.50 0.00 4.50 52.00 11.00

09時02分01秒 all 44.00 0.00 48.50 7.25 0.25

09時02分03秒 all 36.91 0.00 30.42 27.93 4.74

Average: all 37.64 0.00 20.82 34.30 7.24

sar -I 14 -o int14.file 2 10

每2秒報告一次14号中斷的情況,共輸出10行,并把結果儲存到檔案int14.file内

Report statistics on IRQ 14 for each 2 seconds. 10 lines are displayed. Data are stored in a file called int14.file.

sar -r -n DEV -f /var/log/sa/sa16

列出每天儲存在/var/log/sa/sa16内的記憶體、交換分區、網絡活動情況

Display memory, swap space and network statistics saved in daily data file ’sa16’.

sar -A

列出儲存的當天的活動檔案内容

Display all the statistics saved in current daily data file.

繼續閱讀