[AIX 운영 체제와 장치 관리 16] 시스템 계정 관리 — 계정 시스템 설정, sar·timex·acctcom·acctprc1·ac·pac로 보기, holidays 파일, 계정 데이터 수집
https://archive.horanglab.com/posts/aix-osdev-16
핵심 정리
- 계정 설정 순서: nulladm로 wtmp·pacct 권한 → holidays에 연도·주 시간·공휴일 →
/etc/rc에 startup →/etc/filesystems에account = true→/etc/qconfig에acctfile→ adm으로 nite·fiscal·sum 디렉터리 → adm crontab에 dodisk·ckpacct·runacct·monacct → crontab 제출. 긴 사용자 이름이면-X와 x 디렉터리를 씁니다. - sar는 sadc가 돌아야 하며 보통 root crontab의 sa1·sa2로 운영합니다.
timex -s는 명령 실행 중 sar 항목 전체를,-o·-p는 계정이 켜져 있어야 씁니다. - 끝난 프로세스는
acctcom(예:-O 2)으로, 사용자별 CPU는 acctprc1 → acctprc2 → prtacct로, 접속 시간은ac(-p), 디스크는acctmerg -a1 -2,13 -h, 프린터는pac -P로 봅니다. - holidays 파일이 낡으면 acctcon1이 root와 adm에 메일을 보냅니다. 토·일과 나열한 공휴일은 비주 시간이며 공휴일은 20개 이하가 안전합니다.
- 접속 기록은 login·init이
/etc/utmp·/var/adm/wtmp에, 프로세스 기록은 accton이/var/adm/pacct에(명령 이름 앞 8자, WLM 클래스 키 포함), 디스크는 dodisk, 프린터는 qdaemon이/var/adm/qacct에, 요금은 chargefee가/var/adm/fee에 씁니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 6.1 (5.3판과 거의 같음, 일부 절 추가) |
| 원문 | Operating system and device management — 5.3판 229242쪽, 6.1판 161171쪽 |
| 관련 명령어 | nulladm, startup, dodisk, ckpacct, runacct, monacct, crontab, sar, sadc, time, timex, acctcom, acctprc1, acctprc2, prtacct, ac, acctmerg, pac |
| 관련 파일 | /etc/acct/holidays, /etc/rc, /etc/filesystems, /etc/qconfig, /var/spool/cron/crontabs/adm, /var/adm/pacct, /var/adm/wtmp |
시스템 계정에는 여러 작업이 있습니다. 계정 시스템 설정, CPU 사용량 보기, 계정 프로세스 보기 등이 있습니다.
계정 시스템 설정
계정 시스템을 설정할 수 있습니다.
이 절차를 하려면 root 권한이 있어야 합니다.
아래는 계정 시스템을 설정하는 단계의 개요입니다. 더 자세한 정보는 각 단계에 나온 명령과 파일을 봅니다.
- nulladm 명령으로 각 파일의 접근 권한이 올바른지 확인합니다. 파일 소유자와 그룹에는 읽기(r)·쓰기(w), 다른 사용자에게는 읽기(r) 권한이어야 합니다. 다음을 입력합니다.
/usr/sbin/acct/nulladm wtmp pacct
이렇게 하면 pacct와 wtmp 파일에 접근할 수 있습니다.
2. /etc/acct/holidays 파일에 주 시간(prime time)으로 정한 시간과 그해 공휴일 일정을 반영합니다.
참고: 주석 줄은 줄의 첫 문자가 별표(*)이면 파일 어디에나 올 수 있습니다.
- 주 시간을 정의하려면 첫 데이터 줄(주석이 아닌 첫 줄)의 필드를 24시간제로 채웁니다. 이 줄은 4자리 필드 세 개로 이루어지며 순서는 1) 현재 연도, 2) 주 시간 시작(hhmm), 3) 주 시간 끝(hhmm)입니다.
앞쪽 공백은 무시합니다. 자정은 0000이나 2400으로 입력할 수 있습니다. 예를 들어 2000년, 주 시간이 오전 8시에 시작해 오후 5시에 끝나게 하려면 다음을 입력합니다.
2000 0800 1700
그해 회사 공휴일을 정의하려면 다음 데이터 줄들을 채웁니다. 각 줄에는 필드 네 개가 있으며 순서는 1) 연중 날짜, 2) 월, 3) 일, 4) 공휴일 설명입니다.
연중 날짜 필드에는 공휴일이 그해 몇 번째 날인지 1부터 365(윤년은 366)까지의 수를 씁니다. 예를 들어 2월 1일은 32번째 날입니다. 나머지 세 필드는 정보용이며 주석으로 취급합니다. 두 줄짜리 예는 다음과 같습니다.
1 Jan 1 New Year’s Day
332 Nov 28 Thanksgiving Day
/etc/rc파일에 다음 줄을 더하거나, 이미 있으면 줄 앞의 주석 기호(#)를 지워 프로세스 계정을 켭니다.
/usr/bin/su - adm -c /usr/sbin/acct/startup
startup 절차는 계정을 켠 시각을 기록하고 전날의 계정 파일을 정리합니다.
4. 디스크 계정에 넣을 파일 시스템마다 /etc/filesystems 파일의 해당 파일 시스템 스탠자에 다음 줄을 더합니다.
account = true
/etc/qconfig파일의 큐 스탠자에 다음 줄을 더해 프린터 데이터에 쓸 데이터 파일을 지정합니다.
acctfile = /var/adm/qacct
- adm 사용자로
/var/adm/acct/nite,/var/adm/acct/fiscal,/var/adm/acct/sum디렉터리를 만들어 일별과 회계 기간 레코드를 모읍니다.
su - adm
cd /var/adm/acct
mkdir nite fiscal sum
exit
긴 사용자 이름을 쓰려면 대신 다음 명령을 씁니다.
su - adm
cd /var/adm/acct
mkdir nitex fiscalx sumx
exit
/var/spool/cron/crontabs/adm파일에 dodisk, ckpacct, runacct 명령을 넣어 일별 계정 절차가 자동으로 실행되게 합니다. 예:
0 2 * * 4 /usr/sbin/acct/dodisk
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct
2>/var/adm/acct/nite/accterr
긴 사용자 이름을 쓰려면 대신 다음 줄을 더합니다.
0 2 * * 4 /usr/sbin/acct/dodisk -X
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct -X
2>/var/adm/acct/nitex/accterr
첫째 줄은 매주 목요일(4) 오전 2시(0 2)에 디스크 계정을 시작합니다. 둘째 줄은 매일(*) 매시 5분(5 *)에 활성 데이터 파일의 무결성 검사를 시작합니다. 셋째 줄은 월요일부터 토요일(1-6)까지 오전 4시(0 4)에 대부분의 계정 절차를 실행하고 활성 데이터 파일을 처리합니다. 이 시각이 시스템 운영 시간과 맞지 않으면 항목을 조정합니다.
참고: /var/spool/cron/crontabs/adm 파일을 편집하려면 root 사용자 권한이 있어야 합니다.
8. /var/spool/cron/crontabs/adm 파일에 monacct 명령을 넣어 월간 계정 요약이 자동으로 실행되게 합니다. 예를 들어 다음을 입력합니다.
15 5 1 * * /usr/sbin/acct/monacct
긴 사용자 이름을 쓰려면 대신 다음 줄을 더합니다.
15 5 1 * * /usr/sbin/acct/monacct -X
보고서를 끝낼 수 있도록 이 절차를 충분히 일찍 예약합니다. 이 예는 매달 1일 오전 5시 15분에 절차를 시작합니다.
9. 편집한 cron 파일을 제출하려면 다음을 입력합니다.
crontab /var/spool/cron/crontabs/adm
관련 개념
- 파일 시스템 자동 정리 명령 — skulker 명령으로 원치 않는 파일을 지워 파일 시스템을 정리합니다.
- 시스템 데이터 수집과 보고 — 시스템이 자동으로 데이터를 모으고 보고서를 만들도록 설정할 수 있습니다.
- 계정 시스템 활동 보고서, 계정 보고서 요약
관련 작업
- 특정 디렉터리에서 사용자 제한하기, 사용자 정의 파일 시스템 넘침 고치기
- 활성·종료된 계정 프로세스의 프로세스 시간 보기, 계정 프로세스별·사용자별 CPU 사용량 보기
- 프린터나 플로터 사용 계정 레코드 보기
관련 참조
- 계정 보고서와 요약 파일 — 계정 시스템을 켜기 전에 하위 디렉터리 몇 개가 있어야 합니다.
계정 시스템 활동 보기
sar 명령으로 시스템 활동에 관한 서식 있는 정보를 볼 수 있습니다.
시스템 활동 통계를 보려면 sadc 명령이 실행 중이어야 합니다.
참고: sadc 명령을 실행하는 일반적인 방법은 root crontab 파일에 sa1 명령 항목을 넣는 것입니다. sa1 명령은 cron 데몬과 함께 동작하도록 만든 sadc 명령의 셸 프로시저 변형입니다.
기본 시스템 활동 정보를 보려면 다음을 입력합니다.
sar 2 6
첫 번째 수는 표본 간격(초), 두 번째 수는 보여 줄 간격 수입니다. 이 명령의 출력은 다음과 비슷합니다.
arthurd 2 3 000166021000 05/28/92
14:03:40 %usr %sys %wio %idle
14:03:42 4 9 0 88
14:03:43 1 10 0 89
14:03:44 1 11 0 88
14:03:45 1 11 0 88
14:03:46 3 9 0 88
14:03:47 2 10 0 88
Average 2 10 0 88
sar 명령에는 다양한 시스템 통계를 보여 주는 플래그가 많습니다. 쓸 수 있는 모든 통계를 보려면 -A 플래그를 씁니다. 쓸 수 있는 통계와 그 플래그 목록은 sar 명령을 봅니다.
참고: 일별 시스템 활동 보고서가 /var/adm/sa/sadd에 기록되게 하려면 root crontab 파일에 sa2 명령 항목을 넣습니다. sa2 명령은 cron 데몬과 함께 동작하도록 만든 sar 명령의 셸 프로시저 변형입니다.
명령 실행 중 계정 시스템 활동 보기
특정 명령이 실행되는 동안의 시스템 활동에 관한 서식 있는 정보를 볼 수 있습니다.
timex 명령의 -o와 -p 플래그를 쓰려면 시스템 계정이 켜져 있어야 합니다.
time과 timex 명령으로 특정 명령이 실행되는 동안의 시스템 활동 정보를 볼 수 있습니다.
특정 명령의 경과 시간, 사용자 시간, 시스템 실행 시간을 보려면 다음을 입력합니다.
time CommandName
또는
timex CommandName
특정 명령이 실행되는 동안의 전체 시스템 활동(sar 명령이 보고하는 모든 데이터 항목)을 보려면 다음을 입력합니다.
timex -s CommandName
timex 명령에는 플래그가 두 개 더 있습니다. -o 플래그는 명령과 그 모든 자식이 읽거나 쓴 총 블록 수를 보고합니다. -p 플래그는 명령과 그 모든 자식의 프로세스 계정 레코드를 모두 나열합니다.
활성 계정 프로세스의 프로세스 시간 보기
활성 프로세스의 프로세스 시간을 볼 수 있습니다.
acctcom 명령은 총 계정 레코드 형식(acct 파일 형식)의 입력을 읽습니다. 곧 프로세스 계정이 켜져 있거나 과거에 실행한 적이 있어야 합니다.
ps 명령에는 보여 줄 정보를 맞추는 플래그가 많습니다.
커널 프로세스를 뺀 모든 활성 프로세스의 전체 목록을 만들려면 다음을 입력합니다.
ps -ef
터미널과 연결된 모든 프로세스 목록도 볼 수 있습니다. 다음을 입력합니다.
ps -al
두 방법 모두 프로세스마다 여러 열을 보여 주며, 여기에는 분과 초 단위의 현재 CPU 시간이 들어 있습니다.
관련 작업
- 계정 시스템 설정
종료된 계정 프로세스의 프로세스 시간 보기
끝난 프로세스의 프로세스 시간을 볼 수 있습니다.
acctcom 명령은 총 계정 레코드 형식(acct 파일 형식)의 입력을 읽습니다. 곧 프로세스 계정이 켜져 있거나 과거에 실행한 적이 있어야 합니다.
프로세스 계정 기능은 startup 명령으로 켜며, 보통 시스템 초기화 때 /etc/rc 파일의 호출로 시작합니다. 프로세스 계정 기능이 실행 중이면 끝난 프로세스마다 시작·종료 시각이 담긴 레코드가 /var/adm/pacct(총 계정 레코드 파일)에 기록됩니다. acctcom 명령으로 pacct 파일의 프로세스 시간 정보를 볼 수 있습니다. 이 명령에는 보여 줄 프로세스를 유연하게 지정하는 플래그가 많습니다.
예를 들어 최소 CPU 초 이상 실행된 모든 프로세스를 보려면 -O 플래그를 써서 다음을 입력합니다.
acctcom -O 2
이 명령은 2초 이상 실행된 모든 프로세스의 레코드를 보여 줍니다. 입력 파일을 지정하지 않으면 acctcom 명령은 /var/adm/pacct(원문은 디렉터리)에서 입력을 읽습니다.
관련 작업
- 계정 시스템 설정
계정 프로세스별 CPU 사용량 보기
acctprc1 명령으로 CPU 사용량에 관한 서식 있는 보고서를 볼 수 있습니다.
acctprc1 명령에는 총 계정 레코드 형식(acct 파일 형식)의 입력이 필요합니다. 곧 프로세스 계정이 켜져 있거나 과거에 실행한 적이 있어야 합니다.
프로세스별 CPU 사용량 보고서를 만들려면 다음을 입력합니다.
acctprc1 </var/adm/pacct
관련 작업
- 계정 시스템 설정
사용자별 CPU 계정 사용량 보기
acctprc1과 prtacct 명령을 함께 써서 사용자별 CPU 사용량 보고서를 볼 수 있습니다.
acctprc1, acctprc2, accton 명령에는 총 계정 레코드 형식(acct 파일 형식)의 입력이 필요합니다. 곧 프로세스 계정이 켜져 있거나 과거에 실행한 적이 있어야 합니다.
사용자별 CPU 사용량을 보려면 다음 단계를 따릅니다.
- 다음을 입력해 프로세스별 CPU 사용량 출력 파일을 만듭니다.
acctprc1 </var/adm/pacct >out.file
/var/adm/pacct 파일은 프로세스 계정 레코드의 기본 출력입니다. 대신 보관한 pacct 파일을 지정할 수도 있습니다.
2. 다음을 입력해 앞 단계의 출력으로 바이너리 총 계정 레코드 파일을 만듭니다.
acctprc2 <out.file >/var/adm/acct/nite/daytacct
참고: daytacct 파일은 acctmerg 명령이 다른 총 계정 레코드와 합쳐 일별 요약 레코드 /var/adm/acct/sum(x)/tacct를 만듭니다.
3. prtacct 명령으로 사용자별로 요약한 CPU 사용량 보고서를 봅니다. 다음을 입력합니다.
prtacct </var/adm/acct/nite/daytacct
관련 작업
- 계정 시스템 설정
계정을 위한 접속 시간 사용량 보기
ac 명령으로 모든 사용자, 개별 사용자, 개별 로그인별 접속 시간을 볼 수 있습니다.
ac 명령은 /var/adm/wtmp 파일에서 로그인 정보를 뽑으므로 이 파일이 있어야 합니다. 파일이 만들어지지 않았으면 다음 오류 메시지가 나옵니다.
No /var/adm/wtmp
파일이 너무 차면 wtmp 파일이 더 만들어지며, -w 플래그로 이 파일들을 지정해 접속 시간 정보를 볼 수 있습니다. ac 명령에 관한 자세한 내용은 ac를 봅니다.
모든 사용자의 총 접속 시간을 보려면 다음을 입력합니다.
/usr/sbin/acct/ac
이 명령은 현재 wtmp 파일의 수명 동안 로그인한 모든 사용자의 총 접속 시간(분)을 십진수 하나로 보여 줍니다.
특정 사용자 한 명 이상의 총 접속 시간을 보려면 다음을 입력합니다.
/usr/sbin/acct/ac User1 User2 ...
이 명령은 현재 wtmp 파일의 수명 동안 지정한 사용자들의 모든 로그인 총 접속 시간(분)을 십진수 하나로 보여 줍니다.
개별 사용자별 접속 시간과 총 접속 시간을 보려면 다음을 입력합니다.
/usr/sbin/acct/ac -p User1 User2 ...
이 명령은 지정한 사용자마다 현재 wtmp 파일의 수명 동안의 총 접속 시간(분)을 십진수로 보여 주고, 지정한 모든 사용자의 총 접속 시간도 십진수로 보여 줍니다. 사용자를 지정하지 않으면 wtmp 파일의 수명 동안 로그인한 모든 사용자가 목록에 들어갑니다.
계정을 위한 디스크 공간 사용량 보기
acctmerg 명령으로 디스크 공간 사용 정보를 볼 수 있습니다.
디스크 공간 사용 정보를 보려면 acctmerg 명령에 dacct 파일(디스크 계정)의 입력이 필요합니다. 디스크 사용 계정 레코드는 dodisk 명령이 모읍니다.
디스크 공간 사용 정보를 보려면 다음을 입력합니다.
acctmerg -a1 -2,13 -h </var/adm/acct/nite(x)/dacct
이 명령은 사용자마다 쓴 1KB 블록 수가 담긴 디스크 계정 레코드를 보여 줍니다.
참고: acctmerg 명령은 늘 표준 입력에서 읽으며 추가 파일을 아홉 개까지 읽을 수 있습니다. 명령에 입력을 파이프하지 않으면 파일 하나에서 입력 방향을 바꿔야 하고, 나머지 파일은 방향 바꾸기 없이 지정할 수 있습니다.
프린터나 플로터 사용 계정 레코드 보기
pac 명령으로 프린터나 플로터 사용 계정 레코드를 볼 수 있습니다.
- 프린터 사용 정보를 모으려면 계정 시스템을 설정해 실행 중이어야 합니다. 지침은 계정 시스템 설정을 봅니다.
- 계정 레코드를 원하는 프린터나 플로터는
/etc/qconfig파일의 프린터 스탠자에acctfile=절이 있어야 합니다.acctfile=절에 지정한 파일은 root 사용자나 printq 그룹에 읽기·쓰기 권한을 줘야 합니다. - pac 명령의
-s플래그를 지정하면/etc/qconfig파일의acctfile=절에 지정한 경로 이름에_sum을 붙여 요약 파일 이름을 다시 씁니다. 이 파일은 있어야 하며 root 사용자나 printq 그룹에 읽기·쓰기 권한을 줘야 합니다.
특정 프린터의 모든 사용자에 대한 프린터 사용 정보를 보려면 다음을 입력합니다.
/usr/sbin/pac -PPrinter
프린터를 지정하지 않으면 PRINTER 환경 변수가 기본 프린터를 정합니다. PRINTER 변수가 정의되지 않았으면 기본값은 lp0입니다.
특정 프린터의 특정 사용자에 대한 프린터 사용 정보를 보려면 다음을 입력합니다.
/usr/sbin/pac -PPrinter User1 User2 ...
pac 명령에는 보여 줄 정보를 정하는 다른 플래그도 있습니다.
관련 작업
- 계정 시스템 설정
holidays 파일 갱신
나열한 마지막 공휴일이 지나거나 해가 바뀌면 holidays 파일은 낡게 됩니다. holidays 파일을 갱신할 수 있습니다.
(runacct 명령이 시작한) acctcon1 명령은 /usr/lib/acct/holidays 파일이 낡으면 root와 adm 계정에 메일을 보냅니다.
/var/adm/acct/holidays 파일을 편집해 주 시간과 비주 시간을 구분하도록 낡은 holidays 파일을 갱신합니다.
주 시간은 평일처럼 시스템이 가장 바쁜 기간으로 봅니다. 계정 시스템에서 토요일과 일요일은 늘 비주 시간이며, 나열한 공휴일도 그렇습니다.
holidays 파일에는 세 종류의 항목이 있습니다. 주석, 연도와 주 시간 기간, 그리고 다음 예와 같은 공휴일 목록입니다.
* Prime/Non-Prime Time Table for Accounting System
*
* Curr Prime Non-Prime
* Year Start Start
1992 0830 1700
*
* Day of Calendar Company
* Year Date Holiday
*
* 1 Jan 1 New Year’s Day
* 20 Jan 20 Martin Luther King Day
* 46 Feb 15 President’s Day
* 143 May 28 Memorial Day
* 186 Jul 3 4th of July
* 248 Sep 7 Labor Day
* 329 Nov 24 Thanksgiving
* 330 Nov 25 Friday after
* 359 Dec 24 Christmas Eve
* 360 Dec 25 Christmas Day
* 361 Dec 26 Day after Christmas
주석이 아닌 첫 줄에는 현재 연도(네 자리)와 주 시간의 시작과 끝(각각 네 자리)을 지정해야 합니다. 주 시간과 비주 시간 개념은 계정 프로그램이 계정 레코드를 처리하는 방식에만 영향을 줍니다.
공휴일 목록이 너무 길면 acctcon1 명령이 오류를 내므로 목록을 줄여야 합니다. 20개 이하면 안전합니다. 공휴일을 더 넣으려면 holidays 파일을 매달 편집합니다.
영어 원문
Administering system accounting
There are multiple tasks you can complete for system accounting. These tasks include setting up an accounting system, showing CPU usage, and displaying accounting processes.
Setting up an accounting system
You can set up an accounting system.
You must have root authority to complete this procedure.
The information below is an overview of the steps you must take to set up an accounting system. Refer to the commands and files noted in these steps for more specific information.
- Use the nulladm command to ensure that each file has the correct access permission: read (r) and write (w) permission for the file owner and group and read (r) permission for others by typing:
/usr/sbin/acct/nulladm wtmp pacct
This provides access to the pacct and wtmp files.
- Update the
/etc/acct/holidaysfile to include the hours you designate as prime time and to reflect your holiday schedule for the year.
Note: Comment lines can appear anywhere in the file as long as the first character in the line is an asterisk (*). a. To define prime time, fill in the fields on the first data line (the first line that is not a comment), using a 24-hour clock. This line consists of three 4-digit fields, in the following order: 1) Current year 2) Beginning of prime time (hhmm) 3) End of prime time (hhmm)
Leading blanks are ignored. You can enter midnight as either 0000 or 2400. For example, to specify the year 2000, with prime time beginning at 8:00 a.m. and ending at 5:00 p.m., enter:
2000 0800 1700
- To define the company holidays for the yea, fill in the next data line. Each line contains four fields, in the following order: 1) Day of the year 2) Month 3) Day of the month 4) Description of holiday
The day-of-the-year field contains the number of the day on which the holiday falls and must be a number from 1 through 365 (366 on leap year). For example, February 1st is day 32. The other three fields are for information only and are treated as comments. A two-line example follows:
1 Jan 1 New Year’s Day
332 Nov 28 Thanksgiving Day
- Turn on process accounting by adding the following line to the
/etc/rcfile or by deleting the comment symbol (#) in front of the line if it exists:
/usr/bin/su - adm -c /usr/sbin/acct/startup
The startup procedure records the time that accounting was turned on and cleans up the previous day's accounting files.
- Identify each file system you want included in disk accounting by adding the following line to the stanza for the file system in the
/etc/filesystemsfile:
account = true
- Specify the data file to use for printer data by adding the following line to the queue stanza in the
/etc/qconfigfile:
acctfile = /var/adm/qacct
- As the adm user, create a
/var/adm/acct/nite, a/var/adm/acct/fiscal, a and/var/adm/acct/sumdirectory to collect daily and fiscal period records:
su - adm
cd /var/adm/acct
mkdir nite fiscal sum
exit
For long usernames, use the following commands instead:
su - adm
cd /var/adm/acct
mkdir nitex fiscalx sumx
exit
- Set daily accounting procedures to run automatically by editing the
/var/spool/cron/crontabs/admfile to include the dodisk, ckpacct, and runacct commands. For example:
0 2 * * 4 /usr/sbin/acct/dodisk
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct
2>/var/adm/acct/nite/accterr
For long usernames, add the following lines instead:
0 2 * * 4 /usr/sbin/acct/dodisk -X
5 * * * * /usr/sbin/acct/ckpacct
0 4 * * 1-6 /usr/sbin/acct/runacct -X
2>/var/adm/acct/nitex/accterr
The first line starts disk accounting at 2:00 a.m. (0 2) each Thursday (4). The second line starts a check of the integrity of the active data files at 5 minutes past each hour (5 *) every day (*). The third line runs most accounting procedures and processes active data files at 4:00 a.m. (0 4) every Monday through Saturday (1-6). If these times do not fit the hours your system operates, adjust your entries.
Note: You must have root user authority to edit the /var/spool/cron/crontabs/adm file.
- Set the monthly accounting summary to run automatically by including the monacct command in the
/var/spool/cron/crontabs/admfile. For example, type:
15 5 1 * * /usr/sbin/acct/monacct
For long usernames, add the following line instead:
15 5 1 * * /usr/sbin/acct/monacct -X
Be sure to schedule this procedure early enough to finish the report. This example starts the procedure at 5:15 a.m. on the first day of each month.
- To submit the edited
cronfile, type:
crontab /var/spool/cron/crontabs/adm
Related concepts
Command for cleaning up file systems automatically Use the skulker command to clean up file systems by removing unwanted files. System data collection and reporting You can set up the system to automatically collect data and generate reports. Accounting system activity reports You can generate a report that shows Accounting system activity. Accounting report summary You can generate a report that summarizes raw accounting data.
Related tasks
Restricting users from certain directories You can release disk space and possibly keep it free by restricting access to directories and monitoring disk usage. Fixing a user-defined file system overflow Use this procedure to fix an overflowing user-defined file system. Displaying the process time of active Accounting processes You can display the process time for active processes. Displaying the process time of finished Accounting processes You can display the process time of finished processes. Showing the CPU usage for each accounting process You can display formatted reports about the CPU usage by user with the acctprc1 command. Showing the CPU accounting usage for each user You can display a formatted report about the CPU usage by user with a combination of the acctprc1 and prtacct commands.
Displaying printer or plotter usage accounting records You can display printer or plotter usage accounting records with the pac command.
Related reference
Accounting report and summary files Some subdirectories are needed before you enable the Accounting system.
Displaying Accounting system activity
You can display formatted information about system activity with the sar command.
To display system activity statistics, the sadc command must be running.
Note: The typical method of running the sadc command is to place an entry for the sa1 command in the root crontab file. The sa1 command is a shell-procedure variant of the sadc command designed to work with the cron daemon.
To display basic system-activity information, type:
sar 2 6
where the first number is the number of seconds between sampling intervals and the second number is the number of intervals to display. The output of this command looks something like this:
arthurd 2 3 000166021000 05/28/92
14:03:40 %usr %sys %wio %idle
14:03:42 4 9 0 88
14:03:43 1 10 0 89
14:03:44 1 11 0 88
14:03:45 1 11 0 88
14:03:46 3 9 0 88
14:03:47 2 10 0 88
Average 2 10 0 88
The sar command also offers a number of flags for displaying an extensive array of system statistics. To see all available statistics, use the -A flag. For a list of the available statistics and the flags for displaying them, see the sar command.
Note: To have a daily system activity report written to /var/adm/sa/sadd, include an entry in the root crontab file for the sa2 command. The sa2 command is a shell procedure variant for the sar command designed to work with the cron daemon.
Showing Accounting system activity while running a command
You can display formatted information about system activity while a particular command is running.
The -o and -p flags of the timex command require that system accounting be turned on.
You can use the time and timex commands to display formatted information about system activity while a particular command is running.
To display the elapsed time, user time, and system execution time for a particular command, type:
time CommandName
OR
timex CommandName
To display the total system activity (all the data items reported by the sar command) during the execution of a particular command, type:
timex -s CommandName
The timex command has two additional flags. The -o flag reports the total number of blocks read or written by the command and all of its children. The -p flag lists all of the process accounting records for a command and all of its children.
Displaying the process time of active Accounting processes
You can display the process time for active processes.
The acctcom command reads input in the total accounting record form (acct file format). This implies that you have process accounting turned on or that you have run process accounting in the past.
The ps command offers a number of flags to tailor the information displayed.
To produce a full list of all active processes except kernel processes, type:
ps -ef
You can also display a list of all processes associated with terminals. To do this, type:
ps -al
Both of these usages display a number of columns for each process, including the current CPU time for the process in minutes and seconds.
Related tasks
Setting up an accounting system You can set up an accounting system.
Displaying the process time of finished Accounting processes:
You can display the process time of finished processes.
The acctcom command reads input in the total accounting record form (acct file format). This implies that you have process accounting turned on or that you have run process accounting in the past.
The process accounting functions are turned on with the startup command, which is typically started at system initialization with a call in the /etc/rc file. When the process accounting functions are running, a record is written to /var/adm/pacct (a total accounting record file) for every finished process that includes the start and stop time for the process. You can display the process time information from a pacct file with the acctcom command. This command has a number of flags that allow flexibility in specifying which processes to display.
For example, to see all processes that ran for a minimum number of CPU seconds or longer, use the -O flag, type:
acctcom -O 2
This displays records for every process that ran for at least 2 seconds. If you do not specify an input file, the acctcom command reads input from the /var/adm/pacct directory.
Related tasks
Setting up an accounting system You can set up an accounting system.
Showing the CPU usage for each accounting process
You can display formatted reports about the CPU usage by user with the acctprc1 command.
The acctprc1 command requires input in the total accounting record form (acct file format). This implies that you have process accounting turned on or that you have run process accounting in the past.
To produce a formatted report of CPU usage by process, type:
acctprc1 </var/adm/pacct
Related tasks
Setting up an accounting system You can set up an accounting system.
Showing the CPU accounting usage for each user
You can display a formatted report about the CPU usage by user with a combination of the acctprc1 and prtacct commands.
The acctprc1, acctprc2, or accton Command command requires input in the total accounting record form (acct file format). This implies that you have process accounting turned on or that you have run process accounting in the past.
To show the CPU usage for each user, perform the following steps:
- Produce an output file of CPU usage by process by typing:
acctprc1 </var/adm/pacct >out.file
The /var/adm/pacct file is the default output for process accounting records. You might want to specify an archive pacct file instead.
- Produce a binary total accounting record file from the output of the previous step by typing:
acctprc2 <out.file >/var/adm/acct/nite/daytacct
Note: The daytacct file is merged with other total accounting records by the acctmerg command to produce the daily summary record, /var/adm/acct/sum(x)/tacct.
- Use the Showing the CPU accounting usage for each user command to display a formatted report of CPU usage summarized by the user by typing:
prtacct </var/adm/acct/nite/daytacct
Related tasks
Setting up an accounting system You can set up an accounting system.
Displaying connect time usage for accounting
You can display the connect time of all users, of individual users, and by individual login with the ac command.
The ac command extracts login information from the /var/adm/wtmp file, so this file must exist. If the file has not been created, the following error message is returned:
No /var/adm/wtmp
If the file becomes too full, additional wtmp files are created; you can display connect-time information from these files by specifying them with the -w flag. For more information about the ac command, see ac.
To display the total connect time for all users, type:
/usr/sbin/acct/ac
This command displays a single decimal number that is the sum total connect time, in minutes, for all users who have logged in during the life of the current wtmp file.
To display the total connect time for one or more particular users, type:
/usr/sbin/acct/ac User1 User2 ...
This command displays a single decimal number that is the sum total connect time, in minutes, for the user or users you specified for any logins during the life of the current wtmp file.
To display the connect time by individual user plus the total connect time, type:
/usr/sbin/acct/ac -p User1 User2 ...
This command displays as a decimal number for each user specified equal to the total connect time, in minutes, for that user during the life of the current wtmp file. It also displays a decimal number that is the sum total connect time for all the users specified. If no user is specified in the command, the list includes all users who have logged in during the life of the wtmp file.
Displaying disk space utilization for accounting
You can display disk space utilization information with the acctmerg command.
To display disk space utilization information, the acctmerg command requires input from a dacct file (disk accounting). The collection of disk-usage accounting records is performed by the dodisk command.
To display disk space utilization information, type:
acctmerg -a1 -2,13 -h </var/adm/acct/nite(x)/dacct
This command displays disk accounting records, which include the number of 1 KB blocks utilized by each user.
Note: The acctmerg command always reads from standard input and can read up to nine additional files. If you are not piping input to the command, you must redirect input from one file; the rest of the files can be specified without redirection.
Displaying printer or plotter usage accounting records
You can display printer or plotter usage accounting records with the pac command.
To collect printer usage information, you must have an accounting system set up and running. See Setting up an accounting system for guidelines.
The printer or plotter for which you want accounting records must have an
acctfile=clause in the printer stanza of the/etc/qconfigfile. The file specified in theacctfile=clause must grant read and write permissions to the root user or printq group.If the
-sflag of the pac command is specified, the command rewrites the summary file name by appending_sumto the path name specified by theacctfile=clause in the/etc/qconfigfile. This file must exist and grant read and write permissions to the root user or printq group.
To display printer usage information for all users of a particular printer, type:
/usr/sbin/pac -PPrinter
If you do not specify a printer, the default printer is named by the PRINTER environment variable. If the PRINTER variable is not defined, the default is lp0.
To display printer usage information for particular users of a particular printer, type:
/usr/sbin/pac -PPrinter User1 User2 ...
The pac command offers other flags for controlling what information gets displayed.
Related tasks
Setting up an accounting system You can set up an accounting system.
Updating the holidays file
The Holidays file is out of date after the last holiday listed has passed or the year has changed. You can update the Holidays file.
The acctcon1 command (started from the runacct command) sends mail to the root and adm accounts when the /usr/lib/acct/holidays file gets out of date.
Update the out-of-date Holidays file by editing the /var/adm/acct/holidays file to differentiate between prime and nonprime time.
Prime time is assumed to be the period when your system is most active, such as workdays. Saturdays and Sundays are always nonprime times for the accounting system, as are any holidays that you list.
The holidays file contains three types of entries: comments, the year and prime-time period, and a list of holidays as in the following example:
(20줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
The first noncomment line must specify the current year (as four digits) and the beginning and end of prime time, also as four digits each. The concept of prime and nonprime time only affects the way that the accounting programs process the accounting records.
If the list of holidays is too long, the acctcon1 command generates an error, and you will need to shorten your list. You are safe with 20 or fewer holidays. If you want to add more holidays, just edit the holidays file each month.
계정 데이터 수집
시스템 계정을 설정했으면 여러 종류의 계정 데이터를 모으고 처리하기 시작하게 됩니다.
시스템 데이터 수집과 보고
시스템이 자동으로 데이터를 모으고 보고서를 만들도록 설정할 수 있습니다.
데이터를 자동으로 모으려면 adm 그룹 구성원이 계정 시스템을 설정해 두어야 합니다. 계정 시스템을 설정하면 cron 데몬이 다음에 관한 데이터를 만드는 명령을 실행합니다.
- 각 사용자가 시스템에 로그인해 있던 시간
- 처리 장치, 메모리, I/O 자원의 사용
- 각 사용자의 파일이 차지하는 디스크 공간
- 프린터와 플로터 사용
- 특정 명령을 실행한 횟수
시스템은 각 세션과 프로세스가 끝나면 레코드를 씁니다. 이 레코드는 사용자별로 정리한 총 계정(tacct) 레코드로 바뀌어 일별 보고서에 합쳐집니다. 주기적으로 일별 보고서를 합쳐 정한 회계 기간의 합계를 만듭니다. 데이터를 모으고 보고하는 방법과 여러 계정 명령과 파일은 다음 절에서 설명합니다.
계정 데이터는 대부분 자동으로 모이고 처리되지만, adm 그룹 구성원은 키보드에서 특정 명령을 입력해 특정 정보를 얻을 수 있습니다.
관련 작업
- 계정 시스템 설정
관련 참조
- 키보드 명령 — adm 그룹 구성원은 키보드에서 몇몇 명령을 입력할 수 있습니다.
접속 시간 계정 데이터
접속 시간 데이터는 init 명령과 login 명령이 모읍니다.
로그인하면 login 프로그램이 /etc/utmp 파일에 레코드를 씁니다. 이 레코드에는 사용자 이름, 로그인 날짜와 시각, 로그인 포트가 들어 있습니다. who 같은 명령은 이 파일로 어떤 사용자가 어느 디스플레이 스테이션에 로그인해 있는지 알아냅니다. /var/adm/wtmp 접속 시간 계정 파일이 있으면 login 명령은 이 로그인 레코드의 사본을 거기에 더합니다. init과 login 명령에 관한 정보는 init과 login을 봅니다.
login 프로그램이 끝나면(보통 로그아웃할 때) init 명령이 /var/adm/wtmp 파일에 레코드를 하나 더 써서 세션 끝을 기록합니다. 로그아웃 레코드는 사용자 이름이 비어 있다는 점에서 로그인 레코드와 다릅니다. 로그인과 로그아웃 레코드는 모두 utmp.h 파일에 설명된 형식을 따릅니다. utmp.h 파일에 관한 정보는 utmp.h를 봅니다.
acctwtmp 명령도 시스템 종료와 시작에 관한 특수 항목을 /var/adm/wtmp 파일에 씁니다.
관련 개념
- 접속 시간 보고서 — 계정 레코드에는 로그인, 로그아웃, 시스템 종료, lastlogin 레코드가 있습니다.
프로세스 계정 데이터
계정 시스템은 각 프로세스가 실행되는 동안 자원 사용 데이터를 모읍니다.
이 데이터에는 다음이 들어 있습니다.
- 프로세스를 실행하는 사용자와 그룹 번호
- 명령 이름의 앞 8자
- 프로세스가 속한 워크로드 관리자 클래스를 나타내는 64비트 숫자 키
- 프로세스가 쓴 경과 시간과 프로세서 시간
- 메모리 사용
- 전송한 문자 수
- 프로세스를 위해 읽거나 쓴 디스크 블록 수
accton 명령은 이 데이터를 지정한 파일, 보통 /var/adm/pacct 파일에 기록합니다. accton 명령에 관한 자세한 내용은 accton을 봅니다.
관련 명령으로 startup, shutacct, dodisk, ckpacct, turnacct 명령이 있습니다. 이 명령들에 관한 정보는 startup, shutacct, dodisk, ckpacct, turnacct를 봅니다.
관련 개념
- 계정 데이터 보고서 — 여러 종류의 계정 데이터를 모은 뒤 레코드를 처리해 보고서로 바꿉니다.
프로세스 계정 보고서
두 명령이 /var/adm/pacct나 다른 지정 파일에 모인 청구 관련 데이터를 처리합니다.
acctprc1 명령은 사용자 ID를 사용자 이름으로 바꾸고 청구 항목(주 시간과 비주 시간 CPU 시간, 평균 메모리 크기, I/O 데이터)이 든 ASCII 레코드를 씁니다. acctprc2 명령은 이 레코드를 총 계정 레코드로 바꾸고, acctmerg 명령이 이를 일별 보고서에 더합니다. acctmerg 명령에 관한 자세한 내용은 acctmerg를 봅니다.
프로세스 계정 데이터는 시스템 자원 사용을 감시하는 데 쓸 정보도 줍니다. acctcms 명령은 자원 사용을 명령 이름별로 요약합니다. 각 명령을 몇 번 실행했는지, 프로세서 시간과 메모리를 얼마나 썼는지, 자원을 얼마나 집중해서 썼는지(hog factor라고도 함)를 알려 줍니다. acctcms 명령은 시스템 사용에 관한 장기 통계를 만들어 전체 시스템 사용과 명령 사용 빈도 정보를 제공합니다. acctcms 명령에 관한 자세한 내용은 acctcms를 봅니다.
acctcom 명령은 acctcms 명령과 같은 데이터를 다루지만 각 프로세스에 관한 자세한 정보를 제공합니다. 모든 프로세스 계정 레코드를 보거나 특히 관심 있는 레코드만 고를 수 있습니다. 선택 기준으로는 프로세스가 준 부하, 프로세스가 끝난 시간대, 명령 이름, 프로세스를 호출한 사용자나 그룹, 프로세스가 속한 WLM 클래스 이름, 프로세스가 실행된 포트가 있습니다. 다른 계정 명령과 달리 acctcom은 모든 사용자가 실행할 수 있습니다. acctcom 명령에 관한 자세한 내용은 acctcom을 봅니다.
디스크 사용 계정 데이터
많은 계정 정보는 자원이 소비될 때 모입니다. cron 데몬의 지정대로 실행되는 dodisk 명령은 주기적으로 사용자마다 디스크 사용 레코드를 /var/adm/acct/nite(x)/dacct 파일에 씁니다.
이를 위해 dodisk 명령은 다른 명령을 호출합니다. 계정 검색을 얼마나 철저히 하느냐에 따라 diskusg 명령이나 acctdusg 명령으로 데이터를 모을 수 있습니다. acctdisk 명령은 총 계정 레코드를 씁니다. 이 총 계정 레코드는 다시 acctmerg 명령이 일별 계정 보고서를 준비하는 데 씁니다.
dodisk 명령은 사용자의 로그인 디렉터리에서 찾은 파일 링크에 대해 사용자에게 요금을 매기고, 파일마다 요금을 링크 사이에 고르게 나눕니다. 이렇게 하면 파일 사용 비용이 그 파일을 쓰는 모든 사람에게 나뉘고, 사용자가 파일 접근을 포기하면 요금도 사라집니다. dodisk 명령과 cron 데몬에 관한 자세한 내용은 dodisk와 cron을 봅니다.
관련 개념
- 접속 시간 보고서
프린터 사용 계정 데이터
프린터 사용 데이터는 enq 명령과 큐 데몬이 함께 모읍니다.
enq 명령은 사용자 이름, 작업 번호, 인쇄할 파일 이름을 큐에 넣습니다. 파일이 인쇄되면 qdaemon 명령이 사용자 이름, 사용자 번호, 인쇄한 페이지 수가 든 ASCII 레코드를 보통 /var/adm/qacct 파일에 씁니다. 이 레코드를 정렬해 총 계정 레코드로 바꿀 수 있습니다. 이 명령들에 관한 자세한 내용은 enq와 qdaemon을 봅니다.
관련 개념
- 프린터 사용 계정 보고서 —
/var/adm/qacct파일의 ASCII 레코드는 총 계정 레코드로 바꿔 acctmerg 명령이 일별 보고서에 더할 수 있습니다.
요금 계정 데이터
/var/adm/fee 파일에 ASCII 총 계정 레코드를 만들 수 있습니다.
chargefee 명령을 입력해 /var/adm/fee 파일에 ASCII 총 계정 레코드를 만들 수 있습니다. 이 파일은 acctmerg 명령이 일별 보고서에 더합니다.
chargefee와 acctmerg 명령에 관한 정보는 chargefee와 acctmerg를 봅니다.
관련 개념
- 요금 계정 보고서 — chargefee 명령으로 파일 복원, 상담, 자재 같은 서비스에 요금을 매겼다면 ASCII 총 계정 레코드가
/var/adm/fee파일에 기록되고, acctmerg 명령이 일별 보고서에 더합니다.
영어 원문
Collecting accounting data
Once you have setup system accounting you will want to start collecting and processing the different type of accounting data.
System data collection and reporting
You can set up the system to automatically collect data and generate reports.
For data to be collected automatically, a member of the adm group must have been setup as an accounting system. The accounting system setup enables the cron daemon to run the commands that generate data on:
The amount of time each user spends logged in to the system
Usage of the processing unit, memory, and I/O resources
The amount of disk space occupied by each user's files
Usage of printers and plotters
The number of times a specific command is given.
The system writes a record of each session and process after they are completed. These records are converted into total accounting (tacct) records arranged by user and merged into a daily report. Periodically, the daily reports are combined to produce totals for the defined fiscal period. Methods for collecting and reporting the data and the various accounting commands and files are discussed in the following sections.
Although most of the accounting data is collected and processed automatically, a member of the adm group can enter certain commands from the keyboard to obtain specific information.
Related tasks
Setting up an accounting system You can set up an accounting system.
Related reference
Keyboard commands A member of the adm group can enter the following commands from the keyboard.
Connect-time accounting data
Connect-time data is collected by the init command and the login command.
When you log in, the login program writes a record in the /etc/utmp file. This record includes your user name, the date and time of the login, and the login port. Commands, such as who, use this file to find out which users are logged into the various display stations. If the /var/adm/wtmp connect-time accounting file exists, the login command adds a copy of this login record to it. For information about the init and login commands, see init and login.
When your login program ends (normally when you log out), the init command records the end of the session by writing another record in the /var/adm/wtmp file. Logout records differ from login records in that they have a blank user name. Both the login and logout records have the form described in the utmp.h file. For information about the utmp.h file, see utmp.h.
The acctwtmp command also writes special entries in the /var/adm/wtmp file concerning system shutdowns and startups.
Related concepts
Connect-time reports Accounting records include login, logout, system-shutdown, and lastlogin records.
Process accounting data
The Accounting system collects data on resource usage for each process as it runs.
This data includes:
The user and group numbers under which the process runs
The first eight characters of the name of the command
A 64-bit numeric key representing the Workload Manager class that the process belongs to
The elapsed time and processor time used by the process
Memory use
The number of characters transferred
The number of disk blocks read or written on behalf of the process
The accton command records these data in a specified file, usually the /var/adm/pacct file. For more information about the accton command, see accton.
Related commands are the startup command, the shutacct command, the dodisk command, the ckpacct command, and the turnacct command. For information about these commands, see startup, shutacct, dodisk, ckpacct, and turnacct.
Related concepts
Accounting data reports After the various types of accounting data are collected, the records are processed and converted into reports.
Process accounting reports
Two commands process the billing-related data that was collected in the /var/adm/pacct or other specified file.
The acctprc1 command translates the user ID into a user name and writes ASCII records containing the chargeable items (prime and non-prime CPU time, mean memory size, and I/O data). The acctprc2 command transforms these records into total accounting records that are added to daily reports by the acctmerg command. For more information about the acctmerg command, see acctmerg.
Process accounting data also provides information that you can use to monitor system resource usage. The acctcms command summarizes resource use by command name. This provides information on how many times each command was run, how much processor time and memory was used, and how intensely the resources were used (also known as the hog factor). The acctcms command produces long-term statistics on system utilization, providing information on total system usage and the frequency with which commands are used. For more information about the acctcms command, see acctcms.
The acctcom command handles the same data as the acctcms command, but provides detailed information about each process. You can display all process accounting records or select records of particular interest. Selection criteria include the load imposed by the process, the time period when the process ended, the name of the command, the user or group that invoked the process, the name of the WLM class the proces belonged to, and the port at which the process ran. Unlike other accounting commands, acctcom can be run by all users. For more information about the acctcom command, see acctcom.
Disk-usage accounting data
Much accounting information is collected as the resources are consumed. The dodisk command, run as specified by the cron daemon, periodically writes disk-usage records for each user to the /var/adm/acct/nite(x)/dacct file.
To accomplish this, the dodisk command calls other commands. Depending upon the thoroughness of the accounting search, the diskusg command or the acctdusg command can be used to collect data. The acctdisk command is used to write a total accounting record. The total accounting record, in turn, is used by the acctmerg command to prepare the daily accounting report.
The dodisk command charges a user for the links to files found in the user's login directory and evenly divides the charge for each file between the links. This distributes the cost of using a file over all who use it and removes the charges from users when they relinquish access to a file. For more information about the dodisk command and cron daemon, see dodisk and cron.
Related concepts
Connect-time reports Accounting records include login, logout, system-shutdown, and lastlogin records.
Printer-usage accounting data
The collection of printer-usage data is a cooperative effort between the enq command and the queuing daemon.
The enq command enqueues the user name, job number, and the name of the file to be printed. After the file is printed, the qdaemon command writes an ASCII record to a file, usually the /var/adm/qacct file, containing the user name, user number, and the number of pages printed. You can sort these records and convert them to total accounting records. For more information about these commands, see enq and qdaemon.
Related concepts
Printer-Usage accounting report The ASCII record in the /var/adm/qacct file can be converted to a total accounting record to be added to the daily report by the acctmerg command.
Fee accounting data
You can produce an ASCII total accounting record in the /var/adm/fee file.
You can enter the chargefee command to produce an ASCII total accounting record in the /var/adm/fee file. This file will be added to daily reports by the acctmerg command.
For information about the chargefee and acctmerg commands, see chargefee and acctmerg.
Related concepts
Fee accounting report If you used the chargefee command to charge users for services such as file restores, consulting, or materials, an ASCII total accounting record is written in the /var/adm/fee file. This file is added to the daily reports by the acctmerg command.