sar 명령어 (AIX 5.3·6.1)

핵심 정리

  • 운영 체제의 누적 활동 카운터를 정한 간격과 횟수로 보고합니다. sar 2 5는 2초 간격으로 5번(기본은 CPU 사용률)입니다.
  • -o 파일로 이진 데이터를 저장하고 -f 파일로 다시 읽습니다. 기본 데이터 파일은 /var/adm/sa/saDD(DD는 날짜)이며 sa1·sa2를 cron에 걸어 모읍니다.
  • 보고 종류: -u(CPU, 기본), -P ALL(프로세서별), -q(실행 큐), -r(페이징), -d(블록 장치), -b(버퍼), -c(시스템 호출), -w(문맥 교환), -k(커널 프로세스), -m(메시지·세마포어), -v(테이블), -y(tty), -a(파일 접근), -A(모두).
  • -s·-e로 시작·끝 시각, -i로 간격을 골라 저장된 파일에서 뽑고, -x로 날짜·시각을 붙입니다. -M은 묶음마다 머리글을 붙입니다.
  • 공유 프로세서 LPAR에서는 physc와 %entc를, -P에서는 쓰지 않은 용량을 cpu U 줄로 보여 줍니다.
  • 6.1에서 -@ wparname, -P RST, %resc가 생겼습니다. 로컬 활동만 보고합니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 -@, -P RST, %resc, 정렬 옵션과 예제 9~12가 더해짐)
원문 IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5
파일 /usr/sbin/sar, /bin/sar(링크), /var/adm/sa/saDD(일별 데이터)
관련 명령어 sadc, sa1, sa2, vmstat, iostat, topas

목적

시스템 활동 정보를 모으고, 보고하고, 저장합니다.

영어 원문

Collects, reports, or saves system activity information.

구문

text
/usr/sbin/sar [ { -A [ -M ] | [ -a ] [ -b ] [ -c ] [ -d ] [ -k ] [ -m ] [ -q ] [ -r ] [ -u ] [ -v ] [ -w ] [ -y ] [ -M ] } ]
              [ -P processoridentifier, ... | ALL | RST [ -O {sortcolumn=col_name[,sortorder={asc|desc}][,topcount=n]} ] ]
              [ -@ wparname ] [ -e[YYYYMMDD]hh[:mm[:ss]] ] [ -X file ] [ -f file ] [ -i seconds ] [ -o file ]
              [ -s[YYYYMMDD]hh[:mm[:ss]] ] [ -x ] [ Interval [ Number ] ]

RST, 정렬 옵션(-O), -@는 6.1 구문에만 있습니다. 원문 구문은 정렬 옵션 앞의 -O가 빠져 있고 -X도 빠져 있어, 예제 12와 플래그 표에 맞춰 적었습니다.

설명

sar 명령은 운영 체제의 누적 활동 카운터 중 고른 것의 내용을 표준 출력에 씁니다. Number와 Interval 매개변수에 따라 정한 횟수만큼, 정한 초 간격으로 정보를 씁니다. 모은 데이터는 -o file 플래그로 파일에 저장할 수도 있습니다.

sar는 파일에 저장한 레코드를 뽑아 표준 출력에 쓰기도 합니다. 그 파일은 -f로 지정한 파일이거나, 기본으로 오늘의 시스템 활동 일별 데이터 파일 /var/adm/sa/sadd(dd는 오늘 날짜)입니다.

  • -P가 없으면 시스템 전체(모든 프로세서) 통계를 보고하며, 백분율 값은 평균으로, 그 밖에는 합으로 계산합니다. -P를 주면 지정한 프로세서의 활동을 보고합니다. -P ALL은 프로세서마다 통계를 보고한 뒤 시스템 전체 통계를 보고합니다.
  • (6.1) WPAR 환경에서 -P ALL을 쓰고 WPAR에 rset 레지스트리가 연결돼 있으면, 자원 집합 통계와 시스템 전체 통계를 보여 주며 자원 집합에 속한 프로세서 앞에 *를 붙입니다.
  • 플래그로 특정 활동의 정보를 고릅니다. 플래그가 없으면 시스템(과 WPAR) 장치 활동만, -A는 모든 활동을 고릅니다. 통계를 출력하기 전에 활성 프로세서 수와 디스크 수를 출력합니다.

기본 sar(프로세서 사용률 보고)는 주요 시스템 자원을 감시하므로 시스템 활동을 조사할 때 가장 먼저 쓸 만합니다. 프로세서 사용률(user + system)이 100%에 가까우면 작업 부하가 프로세서에 묶인 것입니다. 입출력 대기 시간이 꽤 크면 프로세서 실행이 디스크 입출력을 기다리느라 막힌 것으로, 그 입출력은 필요한 파일 접근이거나 메모리가 모자라 생긴 페이징일 수 있습니다.

참고: 원격 파일 접근을 기다린 시간은 입출력 대기 시간에 쌓이지 않습니다. CPU 사용률과 입출력 대기가 비교적 낮은데 응답 시간이 나쁘면 원격 입출력 대기를 조사해 봅니다. 이를 보여 주는 고수준 명령은 없으므로 trace 데이터가 도움이 됩니다. 실행 중에 출력에 영향을 주는 구성이 바뀌면, 그때까지의 평균값과 경고를 출력하고 바뀐 구성 정보를 출력한 뒤 계속합니다.

입출력 대기 시간의 계산

sar(%wio), vmstat(wa), iostat(% iowait)가 보고하는 wio 시간의 계산법입니다. 프로세서마다 클록 인터럽트(초당 100번)마다 지난 10ms를 usr, sys, wio, idle 중 하나로 셉니다. 사용자 모드로 바빴으면 usr, 커널 모드로 바빴으면 sys, 바쁘지 않았는데 디스크 입출력이 진행 중이면 wio, 아니면 idle입니다.

예전 방식은 입출력을 기다리는 스레드 수와 상관없이 유휴 프로세서를 모두 wio로 셌으므로, 스레드 하나만 입출력을 해도 90% 넘는 wio가 나올 수 있었습니다. 지금의 AIX는 그 프로세서에서 시작한 입출력이 남아 있을 때만 유휴 프로세서를 wio로 셉니다. 그래서 프로세서 4개에 입출력 스레드 하나면 wio는 최대 25%, 12개면 최대 8%입니다. NFS 클라이언트 읽기·쓰기는 VMM을 거치며, biod가 VMM에서 입출력을 기다린 시간도 입출력 대기로 보고합니다.

데이터 저장과 정기 수집

여러 표본과 보고가 필요하면 출력 파일을 지정하고, 표준 출력을 /dev/null로 보내 백그라운드로 실행하면 편합니다. 모든 데이터는 이진 형식으로 data.file에 저장되며, 나중에 -f로 골라 볼 수 있습니다.

bash
sar -A -o data.file interval count > /dev/null &

sar는 sadc라는 프로세스를 불러 시스템 데이터에 접근합니다. 셸 스크립트 /usr/lib/sa/sa1과 /usr/lib/sa/sa2는 cron이 실행하도록 만들어져 일별 통계와 보고를 냅니다. /var/spool/cron/crontabs/adm crontab 파일에 예시 항목이 주석으로 들어 있습니다. 이렇게 모으면 기간 동안의 시스템 사용 특성과 최대 사용 시간대를 알 수 있습니다.

/etc/rc 스크립트의 해당 줄 주석을 풀면 시스템 시작 때 일별 데이터 파일에 더미 레코드를 넣을 수 있습니다. 프로세서 시간이 이전 레코드보다 작은 레코드에는 time change not positive를 보고하는데, 더미 레코드를 넣는 줄을 주석으로 둔 채 재부팅하면 생깁니다.

가상화 환경의 지표

  • AIX 5.3부터 Micro-Partitioning과 SMT(동시 멀티스레딩) 환경에서 physc와 %entc를 보고합니다. physc는 파티션(시스템 전체)이나 논리 프로세서(-P)가 소비한 물리 프로세서 수, %entc는 할당된 용량(시스템 전체)이나 부여된 용량(-P)에 대한 비율입니다.
  • capped 모드에서는 할당보다 더 쓸 수 없고, uncapped 모드에서는 더 쓸 수 있으며 이를 부여된(granted) 할당 용량이라고 합니다. -P를 주고 쓰지 않은 용량이 있으면 cpu id가 U인 줄로 따로 보여 줍니다.
  • (6.1) WPAR 환경에서 %resc(WPAR이 소비한 프로세서 자원 비율)를 보고합니다. 프로세서 한도를 강제한 WPAR에서만 나오며, sar -P는 WPAR의 자원 집합(RSET) 사용률을 R 줄로 보고합니다.

제한: 로컬 활동만 보고합니다. Web-based System Manager(wsm)의 System 응용이나 SMIT의 smit sar 빠른 경로로도 실행할 수 있습니다.

영어 원문

The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the number and interval parameters, writes information the specified number of times spaced at the specified intervals in seconds. The default sampling interval for the number parameter is 1 second. The collected data can also be saved in the file specified by the -o file flag.

The sar command extracts and writes to standard output records previously saved in a file. This file can be either the one specified by the -f flag or, by default, the standard system activity daily data file, the /var/adm/sa/sadd file, where the dd parameter indicates the current day.

Without the -P flag, the sar command reports system-wide (global among all processors) statistics, which are calculated as averages for values expressed as percentages, and as sums otherwise. If the -P flag is given, the sar command reports activity which relates to the specified processor or processors. If -P ALL is given, the sar command reports statistics for each individual processor, followed by system-wide

statistics. If -P ALL is used in a workload partition environment and the WPAR is associated with an rset registry, the resource set statistics and the system-wide statistics are displayed; the processors that belong to the resource set are prefixed with an asterisk symbol (*).

You can select information about specific system activities using flags. If you do not specify any flags, you select only system and WPAR unit activity. Specifying the -A flag selects all activities. The sar command prints the number of processors and the number of disks that are currently active before starting to print the statistics.

The default version of the sar command (processor utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system resources. If processor utilization is near 100 percent (user + system), the workload sampled is processor-bound. If a considerable percentage of time is spent in I/O wait, it implies that processor execution is blocked waiting for disk I/O. The I/O may be required file accesses or it may be I/O associated with paging due to a lack of sufficient memory.

Note: The time the system spends waiting for remote file access is not accumulated in the I/O wait time. If CPU utilization and I/O wait time for a task are relatively low, and the response time is not satisfactory, consider investigating how much time is being spent waiting for remote I/O. Since no high-level command provides statistics on remote I/O wait, trace data may be useful in observing this. If there is a change in system configuration that affects the output of the sar command, sar prints the average values up to the current iteration and then a warning message about the configuration change. It then continues the output, after printing the updated system configuration information.

Methods Used to Compute CPU Disk I/O Wait Time

The AIX operating system contains enhancements to the method used to compute the percentage of processor time spent waiting on disk I/O (wio time). The wio time is reported by the commands sar (%wio), vmstat (wa) and iostat (% iowait).

At each clock interrupt on each processor (100 times a second per processor), a determination is made as to which of the four categories (usr/sys/wio/idle) to place the last 10 ms of time. If the processor was busy in usr mode at the time of the clock interrupt, then usr gets the clock tick added into its category. If the processor was busy in kernel mode at the time of the clock interrupt, then the sys category gets the tick. If the processor was not busy, a check is made to see if any I/O to disk is in progress. If any disk I/O is in progress, the wio category is incremented. If no disk I/O is in progress and the processor is not busy, the idle category gets the tick. The inflated view of wio time results from all idle processors being categorized as wio regardless of the number of threads waiting on I/O. For example, systems with just one thread doing I/O could report over 90 percent wio time regardless of the number of processors it has.

The AIX operating system marks an idle processor as wio if an outstanding I/O was started on that processor. This method can report much lower wio times when just a few threads are doing I/O and the system is otherwise idle. For example, a system with four processors and one thread doing I/O will report a maximum of 25 percent wio time. A system with 12 processors and one thread doing I/O will report a maximum of 8 percent wio time. NFS client reads/writes go through the VMM, and the time that biods spend in the VMM waiting for an I/O to complete is now reported as I/O wait time.

If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command. Direct the standard output data from the sar command to /dev/null and run the sar command as a background process. The syntax for this is: sar -A -o data.file interval count > /dev/null &

All data is captured in binary form and saved to a file (data.file). The data can then be selectively displayed with the sar command using the -f option.

The sar command calls a process named sadc to access system data. Two shell scripts (/usr/lib/sa/sa1 and /usr/lib/sa/sa2) are structured to be run by the cron command and provide daily statistics and reports. Sample stanzas are included (but commented out) in the /var/spool/cron/crontabs/adm crontab file to specify when the cron daemon should run the shell scripts. Collection of data in this manner is useful to characterize system usage over a period of time and determine peak usage hours.

You can insert a dummy record into the standard system activity daily data file at the time of system start by un-commenting corresponding lines in the /etc/rc script. The sar command reports time change not positive for any record where processor times are less than the previous record. This occurs if you reboot the system with the dummy record insertion lines in /etc/rc commented out.

Beginning with AIX 5.3, the sar command reports utilization metrics physc and %entc which are related to Micro-Partitioning® and simultaneous multithreading environments. These metrics will only be displayed on Micro-Partitioning and simultaneous multithreading environments. physc indicates the number of physical processors consumed by the partition (in case of system wide utilization) or logical processor (if the -P flag is specified) and %entc indicates the percentage of the allocated entitled capacity (in case of system wide utilization) or granted entitled capacity (if the -P flag is specified). When the partition runs in capped mode, the partition cannot get more capacity than it is allocated. In uncapped mode, the partition can get more capacity than it is actually allocated. This is called granted entitled capacity. If the -P flag is specified and there is unused capacity, sar prints the unused capacity as separate processor with cpu id U.

Beginning with AIX 6.1, the sar command reports the utilization metric %resc, which is related to the workload partition (WPAR) environment. The %resc metric indicates the percentage of processor resource that the WPAR consumes. This field is displayed only if the processor-resource limit is enforced in the WPAR. The sar -P command reports the resource set (RSET) utilization metrics R for the WPAR.

Restriction: The sar command only reports on local activities.

You can use the System application in Web-based System Manager (wsm) to run this command.

You could also use the System Management Interface Tool (SMIT) smit sar fast path to run this command.

플래그

플래그 설명
-@ wparname 전역 환경에서 WPAR의 프로세서 사용을 보고합니다. WPAR 안에서는 쓸 수 없고, -d, -r, -y, -f, -X와 함께 쓰지 않습니다. 6.1부터
-A -P 없이 쓰면 -abcdkmqruvwy와, -P와 함께 쓰면 -acmuw와 같습니다. -M이 없으면 머리글을 첫 간격의 데이터 앞에 한 번만 묶어 출력하고, -M과 함께 쓰면 간격마다 줄마다 머리글을 붙입니다.
-a 파일 접근 시스템 루틴이 초당 몇 번 불렸는지 보고합니다(아래 표). -P와 함께 쓰면 프로세서별로 보고합니다.
-b 버퍼 활동(전송, 접근, 커널 블록 버퍼 캐시 적중률)을 초당 값으로 보고합니다(아래 표). 대부분의 파일 접근은 커널 블록 버퍼를 거치지 않으므로, 블록 장치나 raw 문자 장치를 직접 열 때 의미가 있습니다.
-c 시스템 호출을 보고합니다(아래 표). -P와 함께 쓰면 프로세서별입니다. sar 자신도 간격에 따라 읽기·쓰기를 꽤 만들므로, 부하 없이 한 번 돌려 sar의 몫을 알아 두면 좋습니다.
-d 테이프를 뺀 블록 장치마다 활동을 보고합니다(아래 표). WPAR에서는 쓸 수 없습니다.
-e[YYYYMMDD]hh[:mm[:ss]] 보고의 끝 시각을 정합니다. 기본은 18:00입니다. 연월일을 YYYYMMDD로 주면 -x가 자동으로 켜지고, 주지 않으면 지정한 시각과 맞는 데이터 파일 첫 레코드의 연월일을 씁니다.
-X file sar·sadc가 만든 파일에서 레코드를 뽑습니다.
-f file -o로 만든 파일에서 레코드를 뽑습니다. 기본은 오늘의 일별 데이터 파일 /var/adm/sa/sadd입니다. Interval·Number를 지정하면 무시합니다. WPAR에서는 쓸 수 없습니다.
-i seconds Seconds에 가장 가까운 간격의 데이터 레코드를 고릅니다. 지정하지 않으면 데이터 파일의 모든 간격을 보고합니다.
-k 커널 프로세스 활동을 보고합니다: kexit/s(초당 끝난 커널 프로세스 수), kproc-ov/s(프로세스 한도 때문에 커널 프로세스를 만들지 못한 횟수), ksched/s(초당 작업에 배정된 커널 프로세스 수).
-M [abckmqruvwy] 중 둘 이상이나 -A와 함께 쓰면, 간격마다 데이터 줄 앞에 해당 머리글을 붙입니다. Interval·Number 없이 쓰면 무시합니다.
-m 초당 메시지(보내기·받기)와 세마포어(만들기·쓰기·없애기) 활동을 보고합니다: msg/s(IPC 메시지 기본 연산 수), sema/s(IPC 세마포어 기본 연산 수). -P와 함께 쓰면 프로세서별입니다.
-o file 읽은 값을 파일에 이진 형식으로 저장합니다. 값마다 별도 레코드이며, 레코드마다 읽은 시각 표시가 있습니다.
-P processoridentifier, ... | ALL | RST 지정한 프로세서의 통계를 보고합니다. ALL은 프로세서마다와 전체를, RST(6.1)는 WPAR에 연결된 rset의 프로세서를 보고합니다. 전역 환경에서 -P와 함께 의미가 있는 것은 -a, -c, -m, -u, -w뿐이며, WPAR 환경에서는 -P에 다른 플래그를 쓰지 않습니다. WPAR에서 보고하는 프로세서별 통계는 늘 시스템 전체 값입니다.
-q 큐 통계를 보고합니다: runq-sz(실행 큐의 평균 커널 스레드 수), %runocc(실행 큐가 차 있던 시간 비율), swpq-sz(VMM 큐에서 자원·입출력을 기다린 평균 커널 스레드 수), %swpocc(스왑 큐가 차 있던 시간 비율). 빈칸은 큐가 비어 있다는 뜻입니다.
-r 페이징 통계를 보고합니다: cycle/s(초당 페이지 교체 순환 수), fault/s(초당 페이지 폴트 수. 입출력 없이 해결되는 것도 포함), slots(페이징 공간의 빈 페이지 수), odio/s(초당 페이징이 아닌 디스크 입출력 수). WPAR에서는 쓸 수 없습니다.
-s[YYYYMMDD]hh[:mm[:ss]] 데이터의 시작 시각을 정해, 그 시각이나 그 뒤의 레코드를 뽑습니다. 기본은 08:00입니다. YYYYMMDD를 주면 -x가 켜지고, 주지 않으면 지정한 시각과 맞는 첫 레코드의 연월일을 씁니다.
-u 프로세서별이나 시스템 전체 통계를 보고합니다(아래 표). -P와 함께 쓰면 프로세서별입니다. 백분율이므로 시스템 전체 값은 프로세서 값의 평균이며, 입출력 대기는 시스템 전체로 정의됩니다.
-v 프로세스, 커널 스레드, i-node, 파일 테이블의 상태를 보고합니다: file-sz, inod-sz, proc-sz, thrd-sz(각 테이블에서 쓰는 항목 수).
-w 시스템 전환 활동을 보고합니다: pswch/s(초당 문맥 교환 수). -P와 함께 쓰면 프로세서별입니다.
-y 초당 tty 장치 활동을 보고합니다: canch/s(정규 입력 큐 문자, 늘 0), mdmin/s(모뎀 인터럽트), outch/s(출력 큐 문자), rawch/s(입력 큐 문자), revin/s(수신 인터럽트), xmtin/s(송신 인터럽트). WPAR에서는 쓸 수 없습니다.
-x 항목마다 날짜와 시각을 보여 줍니다. -s나 -e에 YYYYMMDD를 주면 자동으로 켜집니다.

-a, -b, -c, -d, -u의 열

플래그 열 뜻
-a dirblk/s 특정 파일의 디렉터리 항목을 찾으려고 디렉터리 검색 루틴이 읽은 512바이트 블록 수
-a iget/s 여러 파일 시스템 형식을 지원하는 i-node 조회 루틴의 호출 수
-a lookuppn/s 경로 이름으로 v-node 주소를 찾는 디렉터리 검색 루틴의 호출 수
-b bread/s, bwrit/s 블록 입출력 수(커널이 블록 버퍼 캐시를 관리하려고 하는 것)
-b lread/s, lwrit/s 논리 입출력 요청 수(응용 프로그램이 블록 장치에 낸 읽기·쓰기)
-b pread/s, pwrit/s raw 장치의 입출력 수(버퍼를 거치지 않음)
-b %rcache, %wcache 캐시 적중률 = 100 × (lreads − breads) ÷ lreads
-c exec/s, fork/s exec·fork 시스템 호출 수
-c sread/s, swrit/s read·write 시스템 호출 수
-c rchar/s, wchar/s read·write 시스템 호출로 전송한 문자 수
-c scall/s 시스템 호출 수
-d %busy 장치가 전송 요청을 처리하느라 바빴던 시간 비율
-d avque 디스크로 보내기를 기다리는 평균 요청 수
-d read/s, write/s, blk/s 장치로·에서의 읽기·쓰기 전송(KB/초)
-d avwait, avserv 요청당 평균 대기 시간과 서비스 시간(ms)
-u %usr, %sys 사용자·시스템(커널) 수준에서 실행한 시간 비율
-u %wio 디스크·NFS 입출력 요청이 남아 있는 동안 유휴였던 시간 비율
-u %idle 남은 디스크 입출력 없이 유휴였던 시간 비율
-u physc 소비한 물리 프로세서 수. 기부가 켜진 전용 파티션, 공유 프로세서, SMT일 때
-u %entc 소비한 할당 용량 비율. 공유 프로세서일 때만. 짧은 간격에서는 100%를 넘을 수 있음
-u %resc 소비한 프로세서 자원 비율. 프로세서 한도를 강제한 WPAR만(6.1)

-u의 참고:

  • 다른 내용 옵션이 없으면 시스템 장치 활동을 보고합니다.
  • -P를 쓰고 공유 프로세서로 할당량만큼 쓰고 있으면, 시스템 전체의 쓰지 않은 용량을 cpuid U 줄로 보여 줍니다.
  • uncapped 공유 프로세서 파티션에서 %entc는 프로세서 줄에서는 부여된 용량에 대한 비율, 시스템 전체 줄에서는 할당된 용량에 대한 비율입니다. 프로세서별 사용률은 실제 물리 소비(physc)를 기준으로 계산하며, 시스템 전체는 할당량을 기준으로 하지만 uncapped 파티션에서는 물리 소비를 기준으로 합니다.
  • 계산 기준 시간이 달라지므로 %사용률 필드의 합이 100%를 넘을 수 있습니다.
영어 원문
  • -@ wparname — The -@ flag specifies that the command reports the processor use in WPAR from the global environment. The wparname parameter specifies which WPAR processor statistics are to be reported. Note: The -@ flag is not supported when executed within a workload partition. Note: Do not use the -@ flag with the -d, -r, -y, -f, or -X flags.
  • -A — Without the -P flag, using the -A flag is equivalent to specifying -abcdkmqruvwy. When used with the -P flag, the -A is equivalent to specifying -acmuw. Without the -M flag, headers are only printed once in multiple lines grouped together before the data for the first interval. When this flag is used with the -M flag, each line of data at each iteration is preceded by the appropriate header.
  • -a — Reports use of file access system routines specifying how many times per second several of the system file access routines have been called. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. The following values are displayed: dirblk/s Number of 512-byte blocks read by the directory search routine to locate a directory entry for a specific file. iget/s Calls to any of several i-node lookup routines that support multiple file system types. The iget routines return a pointer to the i-node structure of a file or device. lookuppn/s Calls to the directory search routine that finds the address of a v-node given a path name.
  • -b — Reports buffer activity for transfers, accesses, and cache (kernel block buffer cache) hit ratios per second. Access to most files in Version 3 bypasses kernel block buffering and therefore does not generate these statistics. However, if a program opens a block device or a raw character device for I/O, traditional access mechanisms are used making the generated statistics meaningful. The following values are displayed: bread/s, bwrit/s Reports the number of block I/O operations. These I/Os are generally performed by the kernel to manage the block buffer cache area, as discussed in the description of the lread/s value. lread/s, lwrit/s Reports the number of logical I/O requests. When a logical read or write to a block device is performed, a logical transfer size of less than a full block size may be requested. The system accesses the physical device units of complete blocks and buffers these blocks in the kernel buffers that have been set aside for this purpose (the block I/O cache area). This cache area is managed by the kernel, so that multiple logical reads and writes to the block device can access previously buffered data from the cache and require no real I/O to the device. Application read and write requests to the block device are reported statistically as logical reads and writes. The block I/O performed by the kernel to the block device in management of the cache area is reported as block reads and block writes. pread/s, pwrit/s Reports the number of I/O operations on raw devices. Requested I/O to raw character devices is not buffered as it is for block devices. The I/O is performed to the device directly. %rcache, %wcache Reports caching effectiveness (cache hit percentage). This percentage is calculated as: [(100)x(lreads - breads)/ (lreads)].
  • -c — Reports system calls. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. The following values are displayed: exec/s, fork/s Reports the total number of fork and exec system calls. sread/s, swrit/s Reports the total number of read/write system calls. rchar/s, wchar/s Reports the total number of characters transferred by read/write system calls. scall/s Reports the total number of system calls. Tip: The sar command itself can generate a considerable number of reads and writes depending on the interval at which it is run. Run the sar statistics without the workload to understand the sar command's contribution to your total statistics.
  • -d — Reports activity for each block device with the exception of tape drives. The following data is reported: %busy Reports the portion of time the device was busy servicing a transfer request. avque Reports the average number of requests waiting to be sent to disk. read/s, write/s, blk/s Reports the read-write transfers from or to a device in kilobytes/second. avwait, avserv Average wait time and service time per request in milliseconds. Restriction: The -d flag is restricted in workload partitions.
  • -e[YYYYMMDD] hh[:mm[:ss]] — Sets the ending time of the report. The default ending time is 18:00. • If you specify the year, month, and date in the YYYYMMDD format, then the -x flag is turned on implicitly. • If you do not specify the year, month, and date in the YYYYMMDD format, then the year, month, and date are considered to be that of the first record in the activity data file that matches the specified time
  • -X file — Extracts the records from the file, which is generated by the sar/sadc command.
  • -f file — Extracts records from the file (created by -o file flag). The default value of the file parameter is the current daily data file, the /var/adm/sa/sadd file. Restriction: If you specify the [ interval [ number ] ] parameter, the -f flag is ignored. The -f flag is restricted in workload partitions.
  • -i seconds — Selects data records at seconds as close as possible to the number specified by the Seconds parameter. Otherwise, the sar command reports all seconds found in the data file.
  • -k — Reports kernel process activity. The following values are displayed: kexit/s Reports the number of kernel processes terminating per second. kproc-ov/s Reports the number of times kernel processes could not be created because of enforcement of process threshold limit. ksched/s Reports the number of kernel processes assigned to tasks per second.
  • -M — Enables multiple headers in output when used with at least two combinations of [abckmqruvwy] or with the -A flag. In this mode, each line of data is preceded by the corresponding header at each iteration. Restriction: This flag is ignored when used without [interval [number]].
  • -m — Reports message (sending and receiving) and semaphore (creating, using, or destroying) activities per second. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. The following values are displayed: msg/s Reports the number of IPC message primitives. sema/s Reports the number of IPC semaphore primitives.
  • -o file — Saves the readings in the file in binary form. Each reading is in a separate record and each record contains a tag identifying the time of the reading.
  • -P processoridentifier, ... | ALL

|RST Reports per-processor statistics for the specified processor or processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors. Specifying the RST option reports statistics for the processors present in the rset registry that is associated with the WPAR. Of the flags that specify the statistics to be reported, only the -a, -c, -m, -u, and -w flags are meaningful with the -P flag in the global environment. In the WPAR environment, do not use any flag with the -P flag. Note: The statistics for each processor that the sar command reports for WPAR are always system-wide. -q Reports queue statistics. The following values are displayed: runq-sz Reports the average number of kernel threads in the run queue. %runocc Reports the percentage of the time the run queue is occupied. swpq-sz Reports the average number of kernel threads that are waiting in the virtual memory manager queue for resource, input, or output. %swpocc Reports the percentage of the time the swap queue is occupied. Tip: A blank value in any column indicates that the associated queue is empty. -r Reports paging statistics. The following values are displayed: cycle/s Reports the number of page replacement cycles per second. fault/s Reports the number of page faults per second. This is not a count of page faults that generate I/O, because some page faults can be resolved without I/O. slots Reports the number of free pages on the paging spaces. odio/s Reports the number of non paging disk I/Os per second. Restriction: The -r flag is restricted in workload partitions. -s[YYYYMMDD] hh[:mm[:ss]] Sets 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.

  • If you specify the year, month, and date in the YYYYMMDD format, then the -x flag is turned on implicitly.

  • If you did not specify the year, month, and date in the YYYYMMDD format, then the year, month, and date are considered to be that of the first record in the activity data file that matches the specified time.

  • -u — Reports per processor or system-wide statistics. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. Because the -uflag information is expressed as percentages, the system-wide information is simply the average of each individual processor's statistics. Also, the I/O wait state is defined system-wide and not per processor. The following values are displayed: %idle Reports the percentage of time the processor or processors were idle with no outstanding disk I/O requests. %sys Reports the percentage of time the processor or processors spent in execution at the system (or kernel) level. %usr Reports the percentage of time the processor or processors spent in execution at the user (or application) level. %wio Reports the percentage of time the processor(s) were idle during which the system had outstanding disk/NFS I/O request(s). See detailed description above. physc Reports the number of physical processors consumed. This data will be reported if the partition is dedicated and enabled for donation, or is running with shared processors or simultaneous multithreading enabled. %entc Reports the percentage of entitled capacity consumed. This will be reported only if the partition is running with shared processors. Because the time base over which this data is computed can vary, the entitled capacity percentage can sometimes exceed 100%. This excess is noticeable only with small sampling intervals. %resc Reports the percentage of processor resource consumed. This metric is applicable only for the WPAR environment. It is reported only if the WPAR enforces processor-resource limit. Tips: • The sar command reports system unit activity if no other specific content options are requested. If the -P flag is used and the partition is running with shared processors, and if the partition capacity usage is what is allocated, then a processor row with cpuid U will be reported to show the system-wide unused capacity. If the partition is running with shared processors in uncapped mode, then %entc will report the percentage of granted entitled capacity against each processor row and percentage of allocated entitled capacity in the system-wide processor row. The individual processor utilization statistics is calculated against the actual physical consumption (physc). The system wide statistics is computed against the entitlement and not physical consumption. However, in an uncapped partition, the system wide statistics is still calculated against the physical consumption. • Since the time base over which the data is computed varies, the sum of all of the %utilization fields (%user, %sys, %idle, and %wait) can exceed 100 percent.

  • -v — Reports status of the process, kernel-thread, i-node, and file tables. The following values are displayed: file-sz, inod-sz, proc-sz , thrd-sz Reports the number of entries in use for each table.

  • -w — Reports system switching activity. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. The following value is displayed: pswch/s Reports the number of context switches per second.

  • -y — Reports tty device activity per second. canch/s Reports tty canonical input queue characters. This field is always 0 (zero). mdmin/s Reports tty modem interrupts. outch/s Reports tty output queue characters. rawch/s Reports tty input queue characters. revin/s Reports tty receive interrupts. xmtin/s Reports tty transmit interrupts. Restriction: The -y flag is restricted in workload partitions.

  • -x — Displays the date and time for each entry. The -x flag is turned on implicitly whenever the user specifies the data in the YYYYMMDD format for the -s flag or the -e flag.

보안

접근 제어: 이 명령들은 adm 그룹 구성원에게만 실행(x) 권한을 주어야 합니다.

RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다. 이 문단은 6.1 문서에만 있습니다.

영어 원문

Access Control: These commands should grant execute (x) access only to members of the adm group.

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

예제

  1. 시스템 장치 활동을 보고합니다.
bash
sar
  1. 앞으로 40초 동안 2초마다 tty 활동을 보고합니다(원문 명령에는 -r도 들어 있어 페이징 활동도 함께 나옵니다).
bash
sar -y -r 2 20
  1. 10분 동안 시스템 장치를 지켜보며 데이터를 temp 파일에 저장합니다.
bash
sar -o temp 60 10
  1. 처음 두 프로세서의 활동을 보고합니다.
bash
sar -u -P 0,1
text
cpu  %usr  %sys  %wio  %idle
  0    45    45     5      5
  1    27    65     3      5
  1. 모든 프로세서와 시스템 전체의 메시지, 세마포어, 프로세서 활동을 보고합니다. 프로세서 4개인 시스템의 출력이며, 마지막 줄이 시스템 전체입니다.
bash
sar -mu -P ALL
text
cpu  msgs/s  sema/s  %usr  %sys  %wio  %idle
  0       7       2    45    45     5      5
  1       5       0    27    65     3      5
  2       3       0    55    40     1      4
  3       4       1    48    41     4      7
  -      19       3    44    48     3      5
  1. 공유 프로세서 LPAR에서 모든 프로세서와 시스템 전체의 물리 프로세서 소비와 할당 용량 소비를 봅니다. 논리 프로세서 2개인 시스템의 출력이며, U 줄은 시스템 전체의 쓰지 않은 용량, 마지막 줄은 시스템 전체입니다.
bash
sar -P ALL
text
cpu  %usr  %sys  %wio  %idle  physc  %entc
  0     0     0     0    100   0.02    3.1
  1     0     0     0    100   0.00    1.0
  U     -     -     0     96   0.48   96.0
  -     0     0     0    100   0.02    4.0
  1. 앞으로 40초 동안 2초마다 시스템 호출, 커널 프로세스, 페이징 활동을 세 줄의 머리글을 따로 붙여 보고합니다.
bash
sar -Mckr 2 20
  1. 앞으로 40초 동안 2초마다 모든 활동을 머리글을 여러 벌 붙여 보고합니다.
bash
sar -MA 2 20
  1. 전역 환경에서 WPAR의 프로세서 사용 통계를 보고합니다(6.1).
bash
sar -@ wparname
  1. WPAR 안에서, WPAR에 연결된 rset의 모든 프로세서 활동을 보고합니다(6.1). 논리 프로세서 2개의 RSET에 연결된 WPAR의 출력입니다.
bash
sar -P RST 1 1
text
19:34:39 cpu  %usr  %sys  %wio  %idle  physc
19:34:40   0     0     2     0     98   0.54
           1     0     0     0    100   0.46
           R     0     1     0     99   1.00
  1. WPAR 안에서 모든 프로세서 활동을 보고합니다(6.1). *는 자원 집합에 속한 프로세서입니다.
bash
sar -P ALL 1 1
text
19:34:39 cpu  %usr  %sys  %wio  %idle  physc
19:34:40  *0     0     2     0     98   0.54
          *1     0     0     0    100   0.46
           R     0     1     0     99   1.00
           -     0     1     0     99   1.00
  1. scall/s 열로 정렬해 CPU 상위 10개를 나열합니다(6.1).
bash
sar -c -O sortcolumn=scall/s,sortorder=desc,topcount=10 -P ALL 1
영어 원문
  1. To report system unit activity, enter the following command:
sar
  1. To report current tty activity for each 2 seconds for the next 40 seconds, enter the following command:
sar -y -r 2 20
  1. To watch system unit for 10 minutes and sort data, enter the following command:
sar -o temp 60 10
  1. To report processor activity for the first two processors, enter the following command:
sar -u -P 0,1

This produces output similar to the following:

cpu %usr %sys %wio %idle
0 45 45 5 5
1 27 65 3 5
  1. To report message, semaphore, and processor activity for all processors and system-wide, enter the following command:
sar -mu -P ALL

On a four-processor system, this produces output similar to the following (the last line indicates system-wide statistics for all processors) :

cpu msgs/s sema/s %usr %sys %wio %idle
0 7 2 45 45 5 5
1 5 0 27 65 3 5
2 3 0 55 40 1 4
3 4 1 48 41 4 7
- 19 3 44 48 3 5
  1. To see physical processor consumed and entitlement consumed for all processors system-wide, run sar command in a shared processor logical partition machine, as follows:
sar -P ALL

On a two-logical processor system, this produces output similar to the following (the last line indicates system-wide statistics for all processors, and the line with cpuid U indicates the system-wide Unused capacity):

cpu %usr %sys %wio %idle physc %entc
0 0 0 0 100 0.02 3.1
1 0 0 0 100 0.00 1.0
U - - 0 96 0.48 96.0
- 0 0 0 100 0.02 4.0
  1. To report system call, kernel process, and paging activities with separate headers for each of the three lines of data at each iteration for every 2 seconds for the next 40 seconds, enter the following command:
sar -Mckr 2 20
  1. To report all activities with multiple sets of headers for every 2 seconds for the next 40 seconds, enter the following command:
sar -MA 2 20
  1. To report the processor use statistics in a WPAR from the global environment, enter the following command:
sar -@ wparname
  1. To report the processor activities for all of the processors present in the rset registry associated with the WPAR from inside a WPAR, enter the following command:
sar -P RST 1 1

In a WPAR that is associated with an RSET of two logical processors, the previous command generates a report similar to the following:

19:34:39 cpu %usr %sys %wio %idle physc
19:34:40 0 0 2 0 98 0.54
        1 0 0 0 100 0.46
        R 0 1 0 99 1.00
  1. To report all of the processor activities from inside a WPAR, enter the following command:
sar -P ALL 1 1

In a WPAR that is associated with an RSET of two logical processors, the previous command generates a report similar to the following:

19:34:39 cpu %usr %sys %wio %idle physc
19:34:40 *0 0 2 0 98 0.54
        *1 0 0 0 100 0.46
        R 0 1 0 99 1.00
        - 0 1 0 99 1.00
  1. To list the top ten CPUs, sorted on the scall/s column, enter the following command:
sar -c -O sortcolumn=scall/s,sortorder=desc,topcount=10 -P ALL 1

파일

파일 설명
/usr/sbin/sar sar 명령이 들어 있습니다.
/bin/sar sar 명령에 대한 심볼릭 링크입니다.
/var/adm/sa/sadd 일별 데이터 파일입니다. dd는 그달의 날짜입니다.

관련 명령어: sa1, cron

영어 원문
  • /usr/sbin/sar — Contains the sar command.
  • /bin/sar — Indicates the symbolic link to the sar command.
  • /var/adm/sa/sadd — Indicates the daily data file, where the dd parameter is a number representing the day of the month.

Related reference:

  • sa1 Command

Related information:

  • cron command
  • System accounting
  • keyboard command
  • Simultaneous Multithreading in AIX® Version 7.1 General Programming Concepts

리눅스(GNU)와 다른 점

항목 AIX 5.3·6.1 리눅스 sar(sysstat)
데이터 파일 /var/adm/sa/saDD /var/log/sa/saDD(배포판마다 다름)
수집 sa1·sa2를 adm crontab에 sysstat 서비스·타이머
블록 장치 -d -d(-p로 장치 이름)
메모리 -r(페이징), vmstat로 보완 -r(메모리 사용량), -B(페이징)
네트워크 없음(netstat, entstat) -n DEV
가상화 physc, %entc, -@ %steal

같은 글자라도 뜻이 다른 플래그가 있으니(-r, -b, -y) 리눅스 습관대로 쓰지 않도록 주의합니다.