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的手册页,上面的东西很全,尽量看看原版更助于理解。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章