-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 系统每秒带出、拿出的交换页数
-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.