linux系統分析工具之sar(五)

上面幾篇文章簡單介紹了幾個常見的系統分析工具,此處主要針對工具sar做一些解析
簡介:
sar:收集,報告或保存系統活動信息。其是目前linux上最爲全面的系統分析工具之一,可以從多方面對系統的活動進行報告,如CPU利用率,磁盤I/O,內存的使用等等。(內核需linux2.6以上)
安裝:(OS:ubuntu 12.04 server)
$ sudo apt-get install sysstat
使用:
sar [ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -H ] [ -i interval ] [ -p ] [ -q ] [ -r ] [ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ] [ -m { keyword [,...] | ALL } ] [ -n { keyword [,...] | ALL } ] [ -I { int [,...]
選項:
-A			#等同於指定-bBdHqrRSuvwWy -I SUM -I XALL -m ALL -n ALL -u ALL -P ALL
-b			#IO和傳輸速率統計
   tps				#每秒設備發出的傳輸總數。一次傳輸就是對設備的一個I/O請求,多個邏輯請求可被整合成一個單一的I/O請求。因此一次傳輸具體無法確定大小。
   rtps				#每秒發給設備的讀請求數
   wtps				#每秒發給設備的寫請求數
   bread/s			#每秒從設備讀的數據總數,用blocks表示,等同於扇區數,因此有一個大小512 bytes
   bwrtn/s			#每秒寫到設備的數據總數
-B			#分頁信息
   pgpgin/s			#每秒系統從磁盤置入分頁的千字節數 
   pgpgout/s			#每秒系統從磁盤移出分頁的千字節數
   fault/s			#由系統造成的分頁錯誤數,這不是一個產生的I/ O頁面錯誤數,因爲一些缺頁故障可以解決without I/O
   majflt/s			#系統每秒產生的嚴重故障,這些必須要加載一個存儲頁面從磁盤
   pgfree/s			#系統每秒強加於空閒列表的頁數
   pgscank/s			#每秒頁面交換守護進程已掃描的頁數
   pgscand/s			#每秒直接掃描的頁數
   pgsteal/s			#系統滿足自身的內存需要,每秒從緩存回收的頁數
   %vmeff			#Calculated as pgsteal/pgscan,衡量分頁回收有效性的指標。If it is near 100% then  almost  every  page coming off the tail of the inactive list is being reaped. If it gets too low (e.g. less than 30%) then the virtual memory is having some difficulty.  This field  is  displayed  as zero if no pages have been scanned during the interval of time.
-C			#When reading data from a file, tell sar to display comments that have been inserted by sadc.
-d			#磁盤設備的信息
   tps				#同-b選項的tps         
   rd_sec/s			#從設備讀取的扇區數,每個刪除512bytes
   wr_sec/s			#寫入設備的扇區數
   avgrq-sz			#發給設備的請求的平均大小(in sectors)
   avgqu-sz			#發給設備的請求的平均隊列長度
   await			#設備處理的I/O請求的平均時間(in milliseconds),包含請求在隊列中的時間和處理它們的時間
   svctm			#This field will be removed in a future sysstat version.
   %util			#發給設備的I/O請求的時間佔用CPU時間的百分比
-e [ hh:mm:ss ]		#指定報告結束時間,不指定時間,默認爲18:00:00
-f [ filename ]		#從文件中提取報告,不指定文件默認:/var/log/sysstat/sadd
-h			#幫助信息
-H			#hugepage使用情況
   kbhugfree			#還沒有被分派的內存hugepages的千字節數
   kbhugused			#已被分派的內存hugepages的千字節數
   %hugused			#已被分派的內存hugepages所佔的百分比
-i interval		#Select data records at seconds as close as possible to the number specified by the interval parameter.
-I { int [,...] | SUM | ALL | XALL }		#中斷統計,int爲中斷號,SUM爲每秒接收到的中斷數,ALL爲統計前16箇中斷,XALL顯示所有中斷
-m { keyword [,...] | ALL }		#電源管理信息(Possible keywords are CPU, FAN, FREQ, IN, TEMP and USB)
-n { keyword [,...] | ALL }			#網絡統計信息(Possible  keywords  are DEV, EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP, ETCP, UDP, SOCK6, IP6, EIP6,ICMP6, EICMP6 and UDP6.)
   DEV			#統計來自網絡設備的信息
   EDEV			#統計從網絡設備錯誤信息
   NFS 			#關於NFS客戶端的活動狀態統計
   NFSD			#關於NFS服務端的活動狀態統計
   SOCK			#正在用的套接字的統計信息
   IP			#關於IPv4的網絡流量的統計
   EIP			#關於IPv4網絡錯誤信息的統計
   ICMP			#關於ICMPv4網絡流量的信息統計
   EICMP		#關於ICMPv4錯誤信息的統計
   TCP			#關於TCPv4的網絡流量的統計
   ETCP			#TCPv4的網絡錯誤的統計
   UDP			#UDPv4網絡流量的信息統計
   SOCK6		#正在用的SOCK的信息(IPv6)
   IP6			#關於IPv6的網絡流量報告
   EIP6			#IPv6網絡錯誤信息
   ICMP6		#ICMPv6網絡流量
   EICMP6		#ICMPv6網絡錯誤
   UDP6			#UDPv6網絡流量
-o [ filename ]				#保存顯示的信息到一個文件中,默認在/var/log/sysstat/sadd
-P { cpu [,...] | ALL }			#處理器的統計信息,cpu爲CPU的編號,ALL爲每一個CPU的信息和全局的CPU信息
-p		#顯示設備名字,與-d一起使用
-q		#隊列長度和平均負載
   runq-sz		#運行的隊列長度(number of tasks waiting for run time).
   plist-sz		#在任務列表中的任務數
   ldavg-1		#1分鐘內的負載The load average is calculated as the average number of runnable or running tasks (R state), and the number of tasks in uninterruptible sleep (D state) over the specified interval.
   ldavg-5		#5分鐘內的負載
   ldavg-15		#15分鐘內的負載
   blocked		#當前被阻塞的任務數
-r		#報告內存的使用
   kbmemfree		#可用的空閒內存(kilobytes)
   kbmemused		#已用的內存(kilobytes,This does not take into account memory used by the kernel itself.)
   %memused		#使用內存的百分比
   kbbuffers		#作爲內核緩存區的被使用的內存
   kbcached		#作爲緩存數據的被使用的內存
   kbcommit		#對於現在的工作量需要的內存,是估算多少內存被需要以保證不會內存不足
   %commit		#正在使用的內存佔總內存(RAM+swap)的的百分比
   kbactive		#活動的內存
   kbinact		#不活動的內存
-R			#內存信息
   frmpg/s			#每秒釋放的內存頁,負數代表被指派的內存數(a page has a size of 4 kB or 8 kB)
   bufpg/s			#每秒輔助存儲的頁被用做緩衝區的數
   campg/s			#每秒輔助存儲器重的頁被用做緩存的數目
-s [ hh:mm:ss ]			#設定報告開始的時間,默認爲08:00:00
-S			#交換空間的使用
   kbswpfree			#空閒的交換空間數(kilobytes)
   kbswpused			#被使用的交換空間數
   %swpused			#使用的空間所佔的百分比
   kbswpcad			#用作內存緩衝的交換(kilobytes)
   %swpcad			#用作內存緩衝的空間所佔總的已使用的交換空間的百分比
-t			#讀取文件時,指定時間
-u [ ALL ]		#CPU使用情況,指定ALL表示顯示所有字段
   %user			#在用戶層執行的程序所佔的CPU利用率(Note that this field includes time spent running virtual processors.)
   %usr				#在用戶層執行的程序所佔的CPU利用率(Note that this field NOT includes time spent running virtual processors.)
   %nice			#在用戶層有優先權的程序所佔的CPU利用率
   %system		        #在系統層執行的程序所佔的CPU利用率Note  that this field includes time spent servicing hardware and software interrupts
   %sys				#在系統層執行的程序所佔的CPU利用率Note  that this field NOT include time spent servicing hardware and software interrupts
   %iowait		        #系統因未解決的磁盤IO請求而閒置的時間百分比
   %steal			#顯示當管理程序維護另一個虛擬處理器,虛擬的cpu花在強制等待的時間百分比
   %irq				#CPU服務於硬件中斷所花費的時間的百分比
   %soft			#CPU服務於軟件中斷所花費的時間的百分比
   %guest			#CPU運行一個虛擬處理器所花的時間百分比
   %idle			#系統沒有未解決的磁盤IO請求,CPU閒置的時間百分比
-v                      #Report status of inode, file and other kernel tables
   dentunusd                    #目錄緩存中沒有使用的緩存條目
   file-nr			#系統中使用的文件處理數
   inode-nr			#系統中使用的節點處理數
   pty-nr			#僞終端數
-V			#顯示版本號
-w			#任務的創建和系統轉換狀態
   proc/s			#每秒創建的任務數
   cswch/s		        #每秒的上下文切換數
-W			#交換統計信息
   pswpin/s			#每秒系統引入的交換頁
   pswpout/s		        #每秒系統導出入的交換頁
-y			#TTY設備狀態
   rcvin/s			#在當前串行口每秒收到的中斷數
   xmtin/s			#每秒的傳輸中斷數
   framerr/s		        #每秒的幀錯誤
   prtyerr/s		        #每秒的奇偶校驗誤差
   brk/s			#每秒的破壞
   ovrun/s			#每秒的數據溢出錯誤
示例:
$ sar -u 2 3
$ sar -d 2 3
$ sar -d -o abc.file 2 3
$ sar -r -n DEV -f /var/log/sysstat/sa16  #Display memory and network statistics saved in daily data file 'sa16'
更多詳情需訪問sar的手冊頁,上面的東西很全,儘量看看原版更助於理解。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章