[AIX 성능 도구 11] perfstat API (6) WPAR·RSET·캐시·노드 인터페이스와 변경 이력

핵심 정리

  • (6.1) WPAR 인터페이스: perfstat_wpar_total, perfstat_cpu_total_wpar, perfstat_memory_total_wpar, perfstat_memory_page_wpar. 전역 환경에서는 WPAR ID나 이름을 주고, WPAR 안에서는 name을 NULL로 줍니다.
  • (6.1) RSET 인터페이스: perfstat_cpu_rset, perfstat_cpu_total_rset로 자원 집합(RSET)에 속한 프로세서만의 지표를 얻습니다.
  • 디스크 크기, 프로세서 설명처럼 잘 바뀌지 않는 값은 캐시됩니다. 구성이 바뀌면 perfstat_reset()(전부) 또는 perfstat_partial_reset(name, FLUSH_DISK 등)(일부)을 부릅니다. RESET_DISK_MINMAX는 디스크 어댑터의 최소·최대 서비스 시간을 초기화합니다.
  • (6.1) 노드 인터페이스(perfstat_xxx_node, perfstat_cluster_total, perfstat_node_list, perfstat_cluster_disk)로 클러스터의 원격 노드 지표를 얻습니다. 먼저 perfstat_config(PERFSTAT_ENABLE | PERFSTAT_CLUSTER_STATS, NULL)로 켭니다.
  • 변경 이력은 어느 bos.perf.libperfstat 수준에서 어떤 인터페이스·필드·구조체가 생겼는지 알려 줍니다. 오래된 시스템용 프로그램을 짤 때 봅니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (WPAR·RSET·노드 인터페이스와 6.1 수준 변경 이력은 6.1에만 있음)
원문 Performance Tools Guide and Reference — 5.3판 6장(175182쪽), 6.1판 185216쪽
파일 /usr/include/libperfstat.h, /usr/samples/libperfstat
관련 명령어 wparstat, lswpar, lsrset, vmstat

(6.1) WPAR 인터페이스

WPAR 인터페이스에는 두 종류가 있습니다.

  • WPAR의 구성 요소 집합(프로세서, 메모리 등)에 관한 지표
  • WPAR의 개별 구성 요소(프로세서, 네트워크 인터페이스, 메모리 페이지 등)에 관한 지표

다음 WPAR 인터페이스는 모두 perfstat_subsystem_total_wpar라는 이름 규칙과 공통 형태를 씁니다.

인터페이스 설명
perfstat_cpu_total_wpar WPAR 프로세서 사용 요약 지표
perfstat_memory_total_wpar WPAR 메모리 사용 요약 지표
perfstat_wpar_total WPAR 정보 지표
perfstat_memory_page_wpar WPAR 메모리 페이지 사용 지표

perfstat_memory_page_wpar를 뺀 subsystem_total 인터페이스의 형태는 다음과 같습니다.

text
int perfstat_subsystem_total_wpar(perfstat_id_wpar_t *name,
                             perfstat_subsystem_total_t *userbuff,
                             int sizeof_struct,
                             int desired_number);

perfstat_memory_page_wpar 인터페이스의 형태는 다음과 같습니다.

text
int perfstat_memory_page_wpar(perfstat_id_wpar_t *name,
         perfstat_psize_t *psize,
                             perfstat_subsystem_total_t *userbuff,
                             int sizeof_struct,
                             int desired_number);

모든 인터페이스의 매개변수 사용법은 다음과 같습니다.

매개변수 설명
perfstat_id_wpar_t *name 지표를 가져올 WPAR의 ID나 이름. 참고: WPAR 환경 안에서 부를 때는 NULL이어야 합니다.
perfstat_subsystem_total_t *userbuff 돌려받을 구조체가 들어갈 공간이 충분한 메모리 영역
int sizeof_struct 구조체의 크기(원문 예: perfstat_memory_total_wpar_t)
int desired_number 모을 페이지 크기 통계의 종류 수

오류 없이 복사해 돌려준 구조체 수는 1을 돌려줍니다. 오류가 나면 -1을 돌려줍니다.

이 규칙의 예외는 perfstat_wpar_total입니다. 이 함수는 name=NULL, userbuff=NULL, desired_number=0이면 쓸 수 있는 perfstat_wpar_total_t 구조체의 전체 수를 돌려줍니다.

perfstat_wpar_total_t 구조체를 모두 가져오려면 다음 가운데 한 방법을 씁니다.

  • 구조체 수를 알아내 모두 담을 메모리를 한 번에 잡은 다음, 해당 API를 한 번 불러 모든 구조체를 가져옵니다.
  • 고정된 개수의 구조체를 잡아 두고, 매번 앞 호출이 돌려준 name을 넘기며 API를 되풀이해 다음 묶음을 가져옵니다. 다음 가운데 하나로 시작합니다.
    • wparname을 ""로 설정, 또는 FIRST_WPARNAME
    • wpar_id를 -1로 설정, 또는 FIRST_WPARID

돌아온 wparname이 ""이거나 wpar_id가 -1이 될 때까지 되풀이합니다.

perfstat_id_wpar_t 형은 libperfstat.h 파일에 정의되어 있습니다. 주요 필드는 다음과 같습니다.

필드 설명
spec 공용체에서 WPAR ID, WPAR 이름, RSET 핸들 가운데 무엇을 쓸지 고릅니다.
wpar_id WPAR ID
wparname WPAR 이름
rset WPAR에 연결된 RSET의 핸들
name 나중을 위해 남겨 둔 것. NULL이어야 합니다.

다음 절들에서 인터페이스마다 돌려주는 데이터의 종류와 코드 예를 보여 줍니다.

영어 원문

WPAR Interfaces

The following are two types of WPAR interfaces:

  • The metrics related to a set of components for a WPAR (such as processors, or memory).

  • The specific metrics related to individual components on a WPAR (such as a processor, network interface, or memory page).

All of the following WPAR interfaces use the naming convention perfstat_subsystem_total_wpar, and use a common signature:

  • perfstat_cpu_total_wpar — Retrieves WPAR processor summary usage metrics
  • perfstat_memory_total_wpar — Retrieves WPAR memory summary usage metrics
  • perfstat_wpar_total — Retrieves WPAR information metrics
  • perfstat_memory_page_wpar — Retrieves WPAR memory page usage metrics

The signature used by the subsystem_total interfaces, except for perfstat_memory_page_wpar, is as follows:

text
int perfstat_subsystem_total_wpar(perfstat_id_wpar_t *name,
                             perfstat_subsystem_total_t *userbuff,
                             int sizeof_struct,
                             int desired_number);

The signature used by the perfstat_memory_page_wpar interface is as follows:

text
int perfstat_memory_page_wpar(perfstat_id_wpar_t *name,
         perfstat_psize_t *psize,
                             perfstat_subsystem_total_t *userbuff,
                             int sizeof_struct,
                             int desired_number);

The usage of the parameters for all of the interfaces is as follows:

  • perfstat_id_wpar_t *name — The WPAR ID or WPAR name for which the metrics must be retrieved. Note: When called inside of a WPAR environment, the name must be NULL.
  • perfstat_subsystem_total_t *userbuff — A memory area with enough space for the returned structure.
  • int sizeof_struct — The size of the perfstat_memory_total_wpar_t structure.
  • int desired_number — The number of different page size statistics to be collected.

The number of structures copied and returned without errors use the return value of 1. If there are errors, the return value is -1.

An exception to this scheme is perfstat_wpar_total. For this function, when name=NULL, userbuff=NULL and desired_number=0, the total number of perfstat_wpar_total_t structures available is returned.

To retrieve all perfstat_wpar_total_t structures, select one of the following methods:

  • Determine the number of structures and allocate the required memory to hold all structure at one time. You can then call the appropriate API to retrieve all structures using one call.

  • Allocate a fixed set of structures and repeatedly call the API to get the next number of structures, each time passing the name returned by the previous call. Start the process by using one of the following queries: – wparname set to "" – FIRST_WPARNAME

– wpar_id set to -1 – FIRST_WPARID

Repeat the process until the wparname is returned equal to “ or the wpar_id is returned equal to -1.

The perfstat_id_wpar_total interface returns a set of structures of type perfstat_id_wpar_total_t, which is defined in the libperfstat.h file. Selected fields from the perfstat_id_wpar_total_t structure include:

  • spec — Select WPAR ID, WPAR Name, or the RSET Handle from the union
  • wpar_id — Specifies the WPAR ID
  • wparname — Specifies the WPAR Name
  • rset — Specifies the RSET Handle of the rset associated with the WPAR
  • name — Reserved for future use, must be NULL

The following sections provide examples of the type of data returned and code using each of the interfaces.

(6.1) perfstat_wpar_total 인터페이스

perfstat_wpar_total 인터페이스는 libperfstat.h 파일에 정의된 perfstat_wpar_total_t 구조체 묶음을 돌려줍니다.

perfstat_wpar_total_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
type WPAR 유형
online_cpus 파티션 RSET에 지금 할당된 가상 프로세서 수, 또는 시스템 파티션에 지금 할당된 가상 프로세서 수
online_memory 시스템 파티션에 지금 할당된 메모리 양
cpu_limit 이 WPAR가 쓰는 프로세서 자원의 최대 한도. 1/100 퍼센트 단위입니다.

이 밖에도 여러 지표를 돌려줍니다. 전체 목록은 Files Reference의 libperfstat.h 헤더 파일에서 perfstat_wpar_total_t 부분을 봅니다.

다음 프로그램은 wparstat의 동작을 흉내 내며 전역 환경에서 perfstat_wpar_total을 쓰는 방법을 보여 줍니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_wpar_total_t *winfo;
    perfstat_id_wpar_t wparid;
    int tot, rc, i;
    tot = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (tot < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (tot == 0) {
  printf("No WPARs found in the system\n");
  exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(tot,sizeof(perfstat_wpar_total_t));
    if(winfo==NULL){
 printf("No sufficient memory\n");
 exit(-1);
    }
    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname,FIRST_WPARNAME);
    rc = perfstat_wpar_total(&wparid, winfo, sizeof(perfstat_wpar_total_t), tot);
    if (rc < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0;i<tot;i++){
        printf("Name of the Workload Partition=%s\n",winfo[i].name);
 printf("Workload partition identifier=%u\n",winfo[i].wpar_id);
 printf("Number of Virtual CPUs in partition rset=%d\n",winfo[i].online_cpus);
 printf("Amount of memory currently online in Global Partition=%lld\n",winfo[i].online_memory);
 printf("Number of processor units this partition is entitled to receive=%d\n",winfo[i].entitled_proc_capacity);
 printf("\n");
    }
    return(0);
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Name of the Workload Partition=test
Workload partition identifier=1
Number of Virtual CPUs in partition rset=2
Amount of memory currently online in Global Partition=4096
Number of processor units this partition is entitled to receive=100

다음 코드는 WPAR 환경에서 perfstat_wpar_total을 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_wpar_total_t *winfo;
    perfstat_id_wpar_t wparid;
    int tot, rc, i;
    tot = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (tot < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (tot == 0) {
  printf("No WPARs found in the system\n");
  exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(tot,sizeof(perfstat_wpar_total_t));
    if(winfo==NULL){
 printf("No sufficient memory\n");
 exit(-1);
    }
   rc = perfstat_wpar_total(NULL, winfo, sizeof(perfstat_wpar_total_t), tot);
    if (rc < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0;i<tot;i++){
        printf("Name of the Workload Partition=%s\n",winfo[i].name);
 printf("Workload partition identifier=%u\n",winfo[i].wpar_id);
 printf("Number of Virtual CPUs in partition rset=%d\n",winfo[i].online_cpus);
 printf("Amount of memory currently online in Global Partition=%lld\n",winfo[i].online_memory);
 printf("Number of processor units this partition is entitled to receive=%d\n",winfo[i].entitled_proc_capacity);
 printf("\n");
    }
    return(0);
}
영어 원문

perfstat_wpar_total Interface

The perfstat_wpar_total interface returns a set of structures of type perfstat_wpar_total_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_wpar_total_t structure include:

  • Type — WPAR type.
  • online_cpus — The number of virtual processors currently allocated to the partition rset or the number of virtual processors currently allocated to the system partition.
  • online_memory — The amount of memory currently allocated to the system partition.
  • cpu_limit — The maximum limit of processor resources this WPAR consumes. The processor limit is in 100ths of percentage units.

Several other paging-space-related metrics (such as number of system calls, number of reads, writes, forks, execs, and load average) are also returned. For a complete list of other paging-space-relate metrics, see the perfstat_wpar_total_t section in the libperfstat.h header file in Files Reference.

The following program emulates wparstat behavior and also shows an example of how

perfstat_wpar_total is used from the global environment

(41줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

text
Name of the Workload Partition=test
Workload partition identifier=1
Number of Virtual CPUs in partition rset=2
Amount of memory currently online in Global Partition=4096
Number of processor units this partition is entitled to receive=100

The following code shows an example of how perfstat_wpar_total is used from the WPAR environment:

(37줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

(6.1) perfstat_cpu_total_wpar 인터페이스

perfstat_cpu_total_wpar 인터페이스는 libperfstat.h 파일에 정의된 perfstat_cpu_total_wpar_t 구조체 묶음을 돌려줍니다.

perfstat_cpu_total_wpar_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
processorHz 프로세서 속도(Hz, ODM에서)
description 프로세서 종류(ODM에서)
ncpus WPAR가 쓸 수 있는 현재 활성 프로세서 수
ncpus_cfg 구성된 프로세서 수. 곧 이 AIX가 동시에 다룰 수 있는 최대 프로세서 수
puser 사용자 모드에서 쓴 물리 프로세서 틱의 전체 수
psys 시스템(커널) 모드에서 쓴 물리 프로세서 틱의 전체 수
pidle 대기 중인 I/O 없이 유휴 상태로 쓴 물리 프로세서 틱의 전체 수
pwait 대기 중인 I/O가 있는 채 유휴 상태로 쓴 물리 프로세서 틱의 전체 수

이 밖에도 여러 지표(시스템 호출 수, 읽기·쓰기 수, fork·exec 수, 부하 평균 등)를 돌려줍니다. 전체 목록은 libperfstat.h 헤더 파일의 perfstat_cpu_total_wpar_t 부분을 봅니다.

다음 프로그램은 wparstat의 동작을 흉내 내며 전역 환경에서 perfstat_cpu_total_wpar를 쓰는 방법을 보여 줍니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_cpu_total_wpar_t *cpustats;
    perfstat_id_wpar_t wparid;
    perfstat_wpar_total_t *winfo;
    int i,j,rc,totwpars;
    /* Retrieve total number of WPARs in the system */
    totwpars = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (totwpars < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (totwpars == 0) {
        printf("No WPARs found in the system\n");
        exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(totwpars,sizeof(perfstat_wpar_total_t));
    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname, "test");
    rc = perfstat_wpar_total(&wparid, winfo, sizeof(perfstat_wpar_total_t), totwpars);
    if (rc <= 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0; i < totwpars; i++)
    {
        bzero(&wparid, sizeof(perfstat_id_wpar_t));
        wparid.spec = WPARID;
        wparid.u.wpar_id = winfo[i].wpar_id;
        cpustats=calloc(1,sizeof(perfstat_cpu_total_wpar_t));
        rc =  perfstat_cpu_total_wpar(&wparid, cpustats, sizeof(perfstat_cpu_total_wpar_t), 1);
        if (rc != 1) {
            perror("perfstat_cpu_total_wpar");
            exit(-1);
        }
        for(j=0;j<rc;j++){
           printf("Number of active logical processors in Global=%d\n",cpustats[j].ncpus);
           printf("Processor description=%s\n",cpustats[j].description);
           printf("Processor speed in Hz=%lld\n",cpustats[j].processorHZ);
           printf("Number of process switches=%lld\n",cpustats[j].pswitch);
           printf("Number of forks system calls executed=%lld\n",cpustats[j].sysfork);
           printf("Length of the run queue=%lld\n",cpustats[j].runque);
           printf("Length of the swap queue=%lld\n",cpustats[j].swpque);
        }
    }
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Number of active logical processors in Global=8
Processor description=PowerPC_POWER7
Processor speed in Hz=3304000000
Number of process switches=1995
Number of forks system calls executed=322
Length of the run queue=3
Length of the swap queue=1

다음 코드는 WPAR 환경에서 perfstat_cpu_total_wpar를 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_cpu_total_wpar_t *cpustats;
    perfstat_id_wpar_t wparid;
    perfstat_wpar_total_t *winfo;
    int i,j,rc,totwpars;
    /* Retrieve total number of WPARs in the system */
    totwpars = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (totwpars < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (totwpars == 0) {
        printf("No WPARs found in the system\n");
        exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(totwpars,sizeof(perfstat_wpar_total_t));
    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname, "test");
    rc = perfstat_wpar_total(NULL, winfo, sizeof(perfstat_wpar_total_t), totwpars);
    if (rc <= 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0; i < totwpars; i++)
    {
        bzero(&wparid, sizeof(perfstat_id_wpar_t));
        wparid.spec = WPARID;
        wparid.u.wpar_id = winfo[i].wpar_id;
        cpustats=calloc(1,sizeof(perfstat_cpu_total_wpar_t));
        rc =  perfstat_cpu_total_wpar(NULL, cpustats, sizeof(perfstat_cpu_total_wpar_t), 1);
        if (rc != 1) {
            perror("perfstat_cpu_total_wpar");
            exit(-1);
        }
        for(j=0;j<rc;j++){
           printf("Number of active logical processors in Global=%d\n",cpustats[j].ncpus);
           printf("Processor description=%s\n",cpustats[j].description);
           printf("Processor speed in Hz=%lld\n",cpustats[j].processorHZ);
           printf("Number of process switches=%lld\n",cpustats[j].pswitch);
           printf("Number of forks system calls executed=%lld\n",cpustats[j].sysfork);
           printf("Length of the run queue=%lld\n",cpustats[j].runque);
           printf("Length of the swap queue=%lld\n",cpustats[j].swpque);
        }
    }
}
영어 원문

perfstat_cpu_total_wpar Interface

The perfstat_cpu_total_wpar interface returns a set of structures of type perfstat_cpu_total_wpar_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_cpu_total_wpar_t structure include:

  • processorHz — Processor speed in Hertz (from ODM)
  • Description — Processor type (from ODM)
  • Ncpus — Current number of active processors available to the WPAR
  • ncpus_cfg — Number of configured processors; that is, the maximum number of processors that this copy of AIX® can handle simultaneously
  • Puser — Total number of physical processor ticks spent in user mode
  • Psys — Total number of physical processor ticks spent in system (kernel) mode
  • Piddle — Total number of physical processor ticks spent idle with no I/O pending
  • Pwait — Total number of physical processor ticks spent idle with I/O pending

Several other paging-space-related metrics (such as number of system calls, number of reads, writes, forks, execs, and load average) are also returned. For a complete list of other paging-space-related metrics, see the perfstat_cpu_total_wpar_t section in the libperfstat.h header file.

The following program emulates wparstat behavior and also shows an example of how perfstat_cpu_total_wpar_t is used from the global environment:

(51줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

text
Number of active logical processors in Global=8
Processor description=PowerPC_POWER7
Processor speed in Hz=3304000000
Number of process switches=1995
Number of forks system calls executed=322
Length of the run queue=3
Length of the swap queue=1

The following code shows an example of how perfstat_cpu_total_wpar is used from the WPAR environment:

(51줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

(6.1) perfstat_memory_total_wpar 인터페이스

perfstat_memory_total_wpar 인터페이스는 libperfstat.h 파일에 정의된 perfstat_memory_total_wpar_t 구조체 묶음을 돌려줍니다.

perfstat_memory_total_wpar_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
real_total 전역 실메모리 양(4KB 페이지 단위)
real_free 전역의 사용 가능한 실메모리 양(4KB 페이지 단위)
real_pinned WPAR의 고정 메모리 양(4KB 페이지 단위)
pgins WPAR에서 페이지 인된 페이지 수
pgouts WPAR에서 페이지 아웃된 페이지 수

이 밖에도 여러 지표를 돌려줍니다. 전체 목록은 libperfstat.h 헤더 파일의 perfstat_memory_total_wpar_t 부분을 봅니다.

다음 프로그램은 wparstat의 동작을 흉내 내며 전역 환경에서 perfstat_memory_total_wpar를 쓰는 방법을 보여 줍니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_memory_total_wpar_t *memstats;
    perfstat_id_wpar_t wparid;
    perfstat_wpar_total_t *winfo;
    int i,j,rc,totwpars;
    /* Retrieve total number of WPARs in the system */
    totwpars = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (totwpars < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (totwpars == 0) {
        printf("No WPARs found in the system\n");
        exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(totwpars,sizeof(perfstat_wpar_total_t));
    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname, "test");
    rc = perfstat_wpar_total(&wparid, winfo, sizeof(perfstat_wpar_total_t), totwpars);
    if (rc <= 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0; i < totwpars; i++)
    {
        bzero(&wparid, sizeof(perfstat_id_wpar_t));
        wparid.spec = WPARID;
        wparid.u.wpar_id = winfo[i].wpar_id;
        memstats=calloc(1,sizeof(perfstat_memory_total_wpar_t));
        rc =  perfstat_memory_total_wpar(&wparid, memstats, sizeof(perfstat_memory_total_wpar_t), 1);
        if (rc != 1) {
            perror("perfstat_memory_total_wpar");
            exit(-1);
        }
for(j=0;j<rc;j++){
                printf("Global total real memory=%lld\n",memstats[j].real_total);
                printf("Global free real memory=%lld\n",memstats[j].real_free);
                printf("Real memory which is pinned=%lld\n",memstats[j].real_pinned);
                printf("Real memory which is in use=%lld\n",memstats[j].real_inuse);
                printf("Number of page faults=%lld\n",memstats[j].pgexct);
                printf("Number of pages paged in=%lld\n",memstats[j].pgins);
                printf("Number of pages paged out=%lld\n",memstats[j].pgouts);
        }
    }
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Global total real memory=1048576
Global free real memory=721338
Real memory which is pinned=464
Real memory which is in use=2886
Number of page faults=37176802
Number of pages paged in=1304
Number of pages paged out=64

다음 코드는 WPAR 환경에서 perfstat_memory_total_wpar를 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_memory_total_wpar_t *memstats;
    perfstat_id_wpar_t wparid;
    perfstat_wpar_total_t *winfo;
    int i,j,rc,totwpars;
    /* Retrieve total number of WPARs in the system */
    totwpars = perfstat_wpar_total(NULL, NULL, sizeof(perfstat_wpar_total_t), 0);
    if (totwpars < 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    if (totwpars == 0) {
        printf("No WPARs found in the system\n");
        exit(-1);
    }
    /* allocate enough memory for all the structures */
    winfo = calloc(totwpars,sizeof(perfstat_wpar_total_t));
    /* Retrieve all WPARs */
    bzero(&wparid, sizeof(perfstat_id_wpar_t));
    wparid.spec = WPARNAME;
    strcpy(wparid.u.wparname, "test");
    rc = perfstat_wpar_total(NULL, winfo, sizeof(perfstat_wpar_total_t), totwpars);
    if (rc <= 0) {
        perror("Error in perfstat_wpar_total");
        exit(-1);
    }
    for(i=0; i < totwpars; i++)
    {
        bzero(&wparid, sizeof(perfstat_id_wpar_t));
        wparid.spec = WPARID;
        wparid.u.wpar_id = winfo[i].wpar_id;
        memstats=calloc(1,sizeof(perfstat_memory_total_wpar_t));
        rc =  perfstat_memory_total_wpar(NULL, memstats, sizeof(perfstat_memory_total_wpar_t), 1);
        if (rc != 1) {
            perror("perfstat_memory_total_wpar");
            exit(-1);
        }
for(j=0;j<rc;j++){
                printf("Global total real memory=%lld\n",memstats[j].real_total);
                printf("Global free real memory=%lld\n",memstats[j].real_free);
                printf("Real memory which is pinned=%lld\n",memstats[j].real_pinned);
                printf("Real memory which is in use=%lld\n",memstats[j].real_inuse);
                printf("Number of page faults=%lld\n",memstats[j].pgexct);
                printf("Number of pages paged in=%lld\n",memstats[j].pgins);
                printf("Number of pages paged out=%lld\n",memstats[j].pgouts);
        }
    }
}
영어 원문

perfstat_memory_total_wpar Interface

The perfstat_memory_total_wpar interface returns a set of structures of type perfstat_memory_total_wpar_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_memory_total_wpar_t structure include:

  • real_total — Amount of Global real memory (in units of 4 KB pages)
  • real_free — Amount of Global free real memory (in units of 4 KB pages)
  • real_pinned — Amount of WPAR pinned memory (in units of 4 KB pages)
  • Pgins — Number of WPAR pages paged in
  • Pgouts — Number of WPAR pages paged out

Several other paging-space-related metrics (such as number of system calls, number of reads, writes, forks, execs, and load average) are also returned. For a complete list of other paging-space-related metrics, see the perfstat_memory_total_wpar_t section in the libperfstat.h header file.

The following program emulates wparstat behavior and also shows an example of how perfstat_memory_total_wpar is used from the global environment:

(51줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program produces output that is similar to the following output:

text
Global total real memory=1048576
Global free real memory=721338
Real memory which is pinned=464
Real memory which is in use=2886
Number of page faults=37176802
Number of pages paged in=1304
Number of pages paged out=64

The following code shows an example of how perfstat_memory_total_wpar is used from the WPAR environment:

(51줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

(6.1) perfstat_memory_page_wpar 인터페이스

perfstat_memory_page_wpar 인터페이스는 libperfstat.h 파일에 정의된 perfstat_memory_page_wpar_t 구조체 묶음을 돌려줍니다.

perfstat_memory_page_wpar_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
psize 페이지 크기(바이트)
real_total 전역 실메모리 양(psize 단위)
real_pinned WPAR의 고정 메모리 양(psize 단위)
pgins WPAR에서 페이지 인된 페이지 수
pgouts WPAR에서 페이지 아웃된 페이지 수

이 밖에도 여러 지표를 돌려줍니다. 전체 목록은 libperfstat.h 헤더 파일의 perfstat_memory_page_wpar_t 부분을 봅니다.

다음 프로그램은 vmstat의 동작을 흉내 내며 전역 환경에서 perfstat_memory_page_wpar를 쓰는 방법을 보여 줍니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
int i, psizes, rc;
perfstat_memory_page_wpar_t *pageinfo;
perfstat_id_wpar_t wparid;
wparid.spec = WPARNAME;
strcpy(wparid.u.wparname,"test");
perfstat_psize_t psize;
psize.psize = FIRST_PSIZE;
/* Get the number of page sizes */
psizes = perfstat_memory_page_wpar(&wparid, NULL, NULL, sizeof(perfstat_memory_page_wpar_t),0);
/*check for error */
if (psizes <= 0 ){
    perror("perfstat_memory_page_wpar ");
    exit(-1);
}
/*Allocate enough memory to hold the structures */
pageinfo = (perfstat_memory_page_wpar_t *)calloc(psizes, sizeof(perfstat_memory_page_wpar_t));
/*check for memory allocation */
if (!pageinfo){
   perror("calloc");
   exit(-1);
}
/* call the API and get the data */
rc = perfstat_memory_page_wpar(&wparid, &psize, pageinfo ,
sizeof(perfstat_memory_page_wpar_t), psizes);
/* check the return values for any error */
if (rc <= 0){
    perror("perfstat_memory_page_wpar ");
    exit(-1);
}
for(i=0;i<psizes;i++){
 printf("Page size in bytes=%lld\n",pageinfo[i].psize);
 printf("Number of real memory frames of this page size=%lld\n",pageinfo[i].real_total);
 printf("Number of pages pinned=%lld\n",pageinfo[i].real_pinned);
 printf("Number of pages in use=%lld\n",pageinfo[i].real_inuse);
 printf("Number of page faults=%lld\n",pageinfo[i].pgexct);
 printf("Number of pages paged in=%lld\n",pageinfo[i].pgins);
 printf("Number of pages paged out=%lld\n",pageinfo[i].pgouts);
 printf("Number of page ins from paging space=%lld\n",pageinfo[i].pgspins);
 printf("Number of page outs from paging space=%lld\n",pageinfo[i].pgspouts);
 printf("Number of page scans by clock=%lld\n",pageinfo[i].scans);
 printf("Number of page steals=%lld\n",pageinfo[i].pgsteals);
}
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Page size in bytes=4096
Number of real memory frames of this page size=572640
Number of pages pinned=143
Number of pages in use=2542
Number of page faults=1613483
Number of pages paged in=1296
Number of pages paged out=58
Number of page ins from paging space=0
Number of page outs from paging space=0
Number of page scans by clock=0
Number of page steals=0
Page size in bytes=65536
Number of real memory frames of this page size=29746
Number of pages pinned=20
Number of pages in use=20
Number of page faults=25294
Number of pages paged in=0
Number of pages paged out=0
Number of page ins from paging space=0
Number of page outs from paging space=0
Number of page scans by clock=0
Number of page steals=0
Page size in bytes=0
Number of real memory frames of this page size=0
Number of pages pinned=0
Number of pages in use=0
Number of page faults=0
Number of pages paged in=0
Number of pages paged out=0
Number of page ins from paging space=0
Number of page outs from paging space=0
Number of page scans by clock=0
Number of page steals=0
Page size in bytes=0
Number of real memory frames of this page size=0
Number of pages pinned=0
Number of pages in use=0
Number of page faults=0
Number of pages paged in=0
Number of pages paged out=0
Number of page ins from paging space=0
Number of page outs from paging space=0
Number of page scans by clock=0
Number of page steals=0

다음 코드는 WPAR 환경에서 perfstat_memory_page_wpar를 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
int i, psizes, rc;
perfstat_memory_page_wpar_t *pageinfo;
perfstat_id_wpar_t wparid;
perfstat_psize_t psize;
psize.psize = FIRST_PSIZE;
/* Get the number of page sizes */
psizes = perfstat_memory_page_wpar(&wparid, NULL, NULL, sizeof(perfstat_memory_page_wpar_t),0);
/*check for error */
if (psizes <= 0 ){
    perror("perfstat_memory_page_wpar ");
    exit(-1);
}
/*Allocate enough memory to hold the structures */
pageinfo = (perfstat_memory_page_wpar_t *)calloc(psizes, sizeof(perfstat_memory_page_wpar_t));
/*check for memory allocation */
if (!pageinfo){
   perror("calloc");
   exit(-1);
}
/* call the API and get the data */
rc = perfstat_memory_page_wpar(NULL, &psize, pageinfo ,
sizeof(perfstat_memory_page_wpar_t), psizes);
/* check the return values for any error */
if (rc <= 0){
    perror("perfstat_memory_page_wpar ");
    exit(-1);
}
for(i=0;i<psizes;i++){
 printf("Page size in bytes=%lld\n",pageinfo[i].psize);
 printf("Number of real memory frames of this page size=%lld\n",pageinfo[i].real_total);
 printf("Number of pages pinned=%lld\n",pageinfo[i].real_pinned);
 printf("Number of pages in use=%lld\n",pageinfo[i].real_inuse);
 printf("Number of page faults=%lld\n",pageinfo[i].pgexct);
 printf("Number of pages paged in=%lld\n",pageinfo[i].pgins);
 printf("Number of pages paged out=%lld\n",pageinfo[i].pgouts);
 printf("Number of page ins from paging space=%lld\n",pageinfo[i].pgspins);
 printf("Number of page outs from paging space=%lld\n",pageinfo[i].pgspouts);
 printf("Number of page scans by clock=%lld\n",pageinfo[i].scans);
 printf("Number of page steals=%lld\n",pageinfo[i].pgsteals);
}
}
영어 원문

perfstat_memory_page_wpar Interface

The perfstat_memory_page_wpar interface returns a set of structures of type perfstat_memory_page_wpar_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_memory_page_wpar_t structure include:

  • Psize — Page size in bytes
  • real_total — Amount of Global real memory (in units of the psize)
  • real_pinned — Amount of WPAR pinned memory (in units of psize)
  • Pgins — Number of WPAR pages paged in
  • Pgouts — Number of WPAR pages paged out

Several other paging-space-related metrics (such as number of system calls, number of reads, writes, forks, execs, and load average) are also returned. For a complete list of other paging-space-related metrics, see the perfstat_memory_page_wpar_t section in the libperfstat.h header file.

The following program emulates vmstat behavior and also shows an example of how perfstat_memory_page_wpar is used from the global environment:

(47줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program produces output that is similar to the following output:

(44줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The following code shows an example of how perfstat_memory_page_wpar is used from the WPAR environment:

(45줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

(6.1) RSET 인터페이스

RSET 인터페이스는 RSET(자원 집합)에 관한 프로세서 지표를 보고합니다.

다음 AIX 6.1 RSET 인터페이스는 모두 perfstat_subsystem[_total]_rset이라는 이름 규칙과 공통 형태를 씁니다.

인터페이스 설명
perfstat_cpu_total_rset RSET에 속한 프로세서들의 요약 지표
perfstat_cpu_rset RSET에 속한 프로세서마다의 지표

형태는 다음과 같습니다.

text
int perfstat_cpu_rset(perfstat_wpar_id_t *name,
                       perfstat_cpu_t * userbuff,
                       int sizeof_struct,
                       int desired_number);
int perfstat_cpu_total_rset(perfstat_wpar_id_t *name,
                       perfstat_cpu_total_t * userbuff,
int sizeof_struct,
int desired_number);

모든 인터페이스의 매개변수 사용법은 다음과 같습니다.

매개변수 설명
perfstat_id_wpar_t *name RSET 식별자와, 통계를 얻을 첫 구성 요소 이름(예: cpu0)을 지정합니다. 지정자(RSETHANDLE, WPARID, WPARNAME), WPAR ID·WPAR 이름·RSET 핸들을 지정하는 공용체, 첫 구성 요소 이름을 지정하는 char * 필드가 든 구조체입니다. 하위 시스템의 첫 구성 요소부터 시작하려면 name 매개변수의 char* 필드를 ""(빈 문자열)로 설정합니다. libperfstat.h에 정의된 매크로 FIRST_CPU를 써도 됩니다.
perfstat_cpu[_total]_t *userbuff 돌려받을 구조체들이 들어갈 공간이 충분한 메모리 영역의 포인터
int sizeof_struct sizeof(perfstat_cpu[_total]_t)로 설정합니다.
int desired_number userbuff에 돌려받을 perfstat_cpu[_total]_t 구조체 수

오류 없이 복사해 돌려준 구조체 수를 돌려줍니다(원문은 "1"). 오류가 나면 -1을 돌려줍니다. name 필드는 NULL이나 다음에 쓸 수 있는 구조체의 이름으로 설정됩니다.

예외로 name=NULL, userbuff=NULL, desired_number=0이면 쓸 수 있는 구조체의 전체 수를 돌려줍니다.

어떤 유형의 구조체를 모두 가져오려면 먼저 그 수를 물어 모두 담을 메모리를 한 번에 잡은 다음 해당 API를 한 번 불러 모두 가져옵니다. 아니면 고정된 개수의 구조체를 잡아 두고 매번 앞 호출이 돌려준 name을 넘기며 API를 되풀이합니다. name을 ""나 FIRST_CPU로 시작해 돌아온 name이 ""가 될 때까지 되풀이합니다.

다음 절들에서 인터페이스마다 돌려주는 데이터의 종류와 코드 예를 보여 줍니다.

영어 원문

RSET Interfaces

The RSET interface reports processor metrics related to an RSET.

All of the following AIX 6.1 RSET interfaces use the naming convention perfstat_subsystem[_total]_rset, and use a common signature:

  • perfstat_cpu_total_rset — Retrieves processor summary metrics of the processors in an RSET
  • perfstat_cpu_rset — Retrieves per processor metrics of the processors in an RSET

The signature used by the previous perfstat_memory_page_wpar Interface is as follows:

text
int perfstat_cpu_rset(perfstat_wpar_id_t *name,
                       perfstat_cpu_t * userbuff,
                       int sizeof_struct,
                       int desired_number);
int perfstat_cpu_total_rset(perfstat_wpar_id_t *name,
                       perfstat_cpu_total_t * userbuff,
int sizeof_struct,
int desired_number);

The usage of the parameters for all of the interfaces is as follows:

  • perfstat_id_wpar_t *name — Specifies the RSET identifier and the name of the first component (for example, cpu0) for which statistics are desired. A structure containing the specifier, which can be an RSETHANDLE, WPARID, or WPARNAME, a union to specify the wpar ID, or wpar name or rsethandle and a char * field to specify the name of the first component. To start from the first component of a subsystem, set the char* field of the name parameter to "" (empty string). You can also use the macro FIRST_CPU defined in the libperfstat.h file.
  • perfstat_cpu[_total]_t *userbuff — A pointer to a memory area with enough space for the returned structures.
  • int sizeof_struct — Should be set to sizeof(perfstat_cpu[_total]_t).
  • int desired_number — The number of structures of type perfstat_cpu[_total]_t to return in userbuff.

The number of structures copied and returned without errors uses the return value of 1. If there are errors, the return value is -1. The field name is either set to NULL or to the name of the next structure available.

An exception to this scheme is when name=NULL, userbuff=NULL, and desired_number=0, the total number of structures available is returned.

To retrieve all structures of a given type, either ask first for their number, allocate enough memory to hold them all at once, then call the appropriate API to retrieve them all in one call. Else, allocate a fixed set of structures and repeatedly call the API to get the next such number of structures, each time passing the name returned by the previous call. Start the process with the name set to "" or FIRST_CPU, and repeat the process until the name returned is equal to "".

The following sections provide examples of the type of data returned and code using each of the interfaces.

(6.1) perfstat_cpu_rset 인터페이스

perfstat_cpu_rset 인터페이스는 libperfstat.h 파일에 정의된 perfstat_cpu_t 구조체 묶음을 돌려줍니다.

perfstat_cpu_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
name 논리 프로세서 이름(cpu0, cpu1 등)
user 사용자 모드에서 쓴 클록 틱 수
sys 시스템(커널) 모드에서 쓴 클록 틱 수
idle 대기 중인 I/O 없이 유휴 상태로 쓴 클록 틱 수
wait 대기 중인 I/O가 있는 채 유휴 상태로 쓴 클록 틱 수
syscall 실행한 시스템 호출 수

이 밖에도 여러 지표(fork, read, write, exec 수 등)를 돌려줍니다. 전체 목록은 libperfstat.h 헤더 파일의 perfstat_cpu_t 부분을 봅니다.

다음 코드는 전역 환경에서 perfstat_cpu_rset을 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
   int i, retcode, rsetcpus;
   perfstat_id_wpar_t wparid;
   perfstat_cpu_t *statp;
   wparid.spec = WPARNAME;
   strcpy(wparid.u.wparname,NULL);
   /* give the wparname "wpar1" as the identifier */
   strcpy(wparid.u.wparname, "test");
   /* check how many perfstat_cpu_t structures are available */
   rsetcpus =  perfstat_cpu_rset(&wparid, NULL, sizeof(perfstat_cpu_t), 0);
   if (rsetcpus < 0 ){
       perror("perfstat_cpu_rset");
       exit(-1);
   }
   /*allocate memory for perfstat_cpu_t structures */
   statp = (perfstat_cpu_t *)calloc(rsetcpus , sizeof(perfstat_cpu_t));
   if(!statp){
      perror("calloc");
   }
   /*call the API and get the values */
   retcode = perfstat_cpu_rset(&wparid, statp,sizeof(perfstat_cpu_t), rsetcpus);
   if(retcode < 0){
      perror("perfstat_cpu_rset");
   }
   for(i=0;i<retcode;i++){
 printf("Logical processor name=%s\n",statp[i].name);
 printf("Raw number of clock ticks spent in user mode=%lld\n",statp[i].user);
 printf("Raw number of clock ticks spent in system mode=%lld\n",statp[i].sys);
 printf("Raw number of clock ticks spent in idle mode=%lld\n",statp[i].idle);
 printf("Raw number of clock ticks spent in wait mode=%lld\n",statp[i].wait);
   }
   return 0;
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Logical processor name=cpu0
Raw number of clock ticks spent in user mode=2050
Raw number of clock ticks spent in system mode=22381
Raw number of clock ticks spent in idle mode=6863114
Raw number of clock ticks spent in wait mode=3002
Logical processor name=cpu1
Raw number of clock ticks spent in user mode=10
Raw number of clock ticks spent in system mode=651
Raw number of clock ticks spent in idle mode=6876627
Raw number of clock ticks spent in wait mode=42
Logical processor name=cpu2
Raw number of clock ticks spent in user mode=0
Raw number of clock ticks spent in system mode=610
Raw number of clock ticks spent in idle mode=6876712
Raw number of clock ticks spent in wait mode=0
Logical processor name=cpu3
Raw number of clock ticks spent in user mode=0
Raw number of clock ticks spent in system mode=710
Raw number of clock ticks spent in idle mode=6876612
Raw number of clock ticks spent in wait mode=0
Logical processor name=cpu4
Raw number of clock ticks spent in user mode=243
Raw number of clock ticks spent in system mode=1659
Raw number of clock ticks spent in idle mode=6875427
Raw number of clock ticks spent in wait mode=62
Logical processor name=cpu5
Raw number of clock ticks spent in user mode=0
Raw number of clock ticks spent in system mode=207327
Raw number of clock ticks spent in idle mode=6848952
Raw number of clock ticks spent in wait mode=0
Logical processor name=cpu6
Raw number of clock ticks spent in user mode=0
Raw number of clock ticks spent in system mode=207904
Raw number of clock ticks spent in idle mode=6849969
Raw number of clock ticks spent in wait mode=0
Logical processor name=cpu7
Raw number of clock ticks spent in user mode=0
Raw number of clock ticks spent in system mode=207375
Raw number of clock ticks spent in idle mode=6848209
Raw number of clock ticks spent in wait mode=0

다음 코드는 WPAR 환경에서 perfstat_cpu_rset을 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
   int i, retcode, rsetcpus;
   perfstat_id_wpar_t wparid;
   perfstat_cpu_t *statp;
   /* check how many perfstat_cpu_t structures are available */
   rsetcpus =  perfstat_cpu_rset(NULL, NULL, sizeof(perfstat_cpu_t), 0);
   if (rsetcpus < 0 ){
       perror("perfstat_cpu_rset");
       exit(-1);
   }
   /*allocate memory for perfstat_cpu_t structures */
   statp = (perfstat_cpu_t *)calloc(rsetcpus , sizeof(perfstat_cpu_t));
   if(!statp){
      perror("calloc");
   }
   /*call the API and get the values */
   retcode = perfstat_cpu_rset(NULL, statp,sizeof(perfstat_cpu_t), rsetcpus);
   if(retcode < 0){
      perror("perfstat_cpu_rset");
   }
   for(i=0;i<retcode;i++){
 printf("Logical processor name=%s\n",statp[i].name);
 printf("Raw number of clock ticks spent in user mode=%lld\n",statp[i].user);
 printf("Raw number of clock ticks spent in system mode=%lld\n",statp[i].sys);
 printf("Raw number of clock ticks spent in idle mode=%lld\n",statp[i].idle);
 printf("Raw number of clock ticks spent in wait mode=%lld\n",statp[i].wait);
   }
   return 0;
}
영어 원문

perfstat_cpu_rset interface

The perfstat_cpu_rset interface returns a set of structures of type perfstat_cpu_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_cpu_t structure include:

  • name — Logical processor name (cpu0, cpu1, and so on)
  • user — Number of clock ticks spent in user mode
  • sys — Number of clock ticks spent in system (kernel) mode
  • idle — Number of clock ticks spent idle with no I/O pending
  • wait — Number of clock ticks spent idle with I/O pending
  • syscall — Number of system call executed

Several other paging-space-related metrics (such as number of forks, reads, writes, and execs) are also returned. For a complete list of other paging-space-related metrics, see the perfstat_cpu_t section in the libperfstat.h header file.

The following code shows an example of how perfstat_cpu_rset is used from the global environment:

(36줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

(40줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The following code shows an example of how perfstat_cpu_rset is used from the WPAR environment:

(32줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

(6.1) perfstat_cpu_total_rset 인터페이스

perfstat_cpu_total_rset 인터페이스는 libperfstat.h 파일에 정의된 perfstat_cpu_total_t 구조체 묶음을 돌려줍니다.

perfstat_cpu_total_t 구조체의 주요 필드는 다음과 같습니다.

필드 설명
processorHz 프로세서 속도(Hz, ODM에서)
description 프로세서 종류(ODM에서)
ncpus 현재 활성 프로세서 수
ncpus_cfg 구성된 프로세서 수(이 AIX가 동시에 다룰 수 있는 최대 프로세서 수)
ncpus_high 최대 활성 프로세서 수. 곧 마지막 재부팅 이후 활성 프로세서 수의 최댓값
user 사용자 모드에서 쓴 클록 틱의 전체 수
sys 시스템(커널) 모드에서 쓴 클록 틱의 전체 수
idle 대기 중인 I/O 없이 유휴 상태로 쓴 클록 틱의 전체 수
wait 대기 중인 I/O가 있는 채 유휴 상태로 쓴 클록 틱의 전체 수

이 밖에도 여러 지표(fork, read, write, exec 수 등)를 돌려줍니다. 전체 목록은 libperfstat.h 헤더 파일의 perfstat_cpu_total_t 부분을 봅니다.

다음 코드는 전역 환경에서 perfstat_cpu_total_rset 인터페이스를 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_cpu_total_t *cpustats;
    perfstat_id_wpar_t wparid;
    int rc,i;
    wparid.spec = WPARNAME;
    rc =  perfstat_cpu_total_rset(NULL,NULL,sizeof(perfstat_cpu_total_t),0);
    if (rc <= 0) {
        perror("perfstat_cpu_total_rset");
        exit(-1);
    }
    cpustats=calloc(rc,sizeof(perfstat_cpu_total_t));
    if(cpustats==NULL){
       perror("MALLOC error:");
       exit(-1);
    }
    strcpy(wparid.u.wparname,"test");
    rc =  perfstat_cpu_total_rset(&wparid, cpustats, sizeof(perfstat_cpu_total_t), rc);
    if (rc <= 0) {
        perror("perfstat_cpu_total_rset");
        exit(-1);
    }
    for(i=0;i<rc;i++){
    printf("Number of active logical processors=%d\n",cpustats[i].ncpus);
    printf("Number of configured processors=%d\n",cpustats[i].ncpus_cfg);
    printf("Processor description=%s\n",cpustats[i].description);
    printf("Processor speed in Hz=%lld\n",cpustats[i].processorHZ);
    printf("Raw total number of clock ticks spent in user mode=%lld\n",cpustats[i].user);
    printf("Raw total number of clock ticks spent in system mode=%lld\n",cpustats[i].sys);
    printf("Raw total number of clock ticks spent idle=%lld\n",cpustats[i].idle);
    printf("Raw total number of clock ticks spent wait=%lld\n",cpustats[i].wait);
    }
    return 0;
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Number of active logical processors=8
Number of configured processors=8
Processor description=PowerPC_POWER7
Processor speed in Hz=3304000000
Raw total number of clock ticks spent in user mode=86400
Raw total number of clock ticks spent in system mode=30636100
Raw total number of clock ticks spent idle=2826632699
Raw total number of clock ticks spent wait=852000

다음 코드는 WPAR 환경에서 perfstat_cpu_total_rset을 쓰는 예입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(){
    perfstat_cpu_total_t *cpustats;
    perfstat_id_wpar_t wparid;
    int rc,i;
    rc =  perfstat_cpu_total_rset(NULL,NULL,sizeof(perfstat_cpu_total_t),0);
    if (rc <= 0) {
        perror("perfstat_cpu_total_rset");
        exit(-1);
    }
    cpustats=calloc(rc,sizeof(perfstat_cpu_total_t));
    if(cpustats==NULL){
       perror("MALLOC error:");
       exit(-1);
    }
    rc =  perfstat_cpu_total_rset(NULL, cpustats, sizeof(perfstat_cpu_total_t), rc);
    if (rc <= 0) {
        perror("perfstat_cpu_total_rset");
        exit(-1);
    }
    for(i=0;i<rc;i++){
    printf("Number of active logical processors=%d\n",cpustats[i].ncpus);
    printf("Number of configured processors=%d\n",cpustats[i].ncpus_cfg);
    printf("Processor description=%s\n",cpustats[i].description);
    printf("Processor speed in Hz=%lld\n",cpustats[i].processorHZ);
    printf("Raw total number of clock ticks spent in user mode=%lld\n",cpustats[i].user);
    printf("Raw total number of clock ticks spent in system mode=%lld\n",cpustats[i].sys);
    printf("Raw total number of clock ticks spent idle=%lld\n",cpustats[i].idle);
    printf("Raw total number of clock ticks spent wait=%lld\n",cpustats[i].wait);
    }
    return 0;
}
영어 원문

perfstat_cpu_total_rset interface

The perfstat_cpu_total_rset interface returns a set of structures of type perfstat_cpu_total_t, which is defined in the libperfstat.h file.

Selected fields from the perfstat_cpu_t structure include:

  • processorHz — Processor speed in Hertz (from ODM)
  • description — Processor type (from ODM)
  • CPUs — Current number of active processors
  • ncpus_cfg — Number of configured processors (maximum number of processors that this copy of AIX can handle simultaneously)
  • ncpus_high — Maximum number of active processors; that is, the maximum number of active processors since the last reboot
  • User — Total number of clock ticks spent in user mode
  • Sys — Total number of clock ticks spent in system (kernel) mode
  • Idle — Total number of clock ticks spent idle with no I/O pending
  • Wait — Total number of clock ticks spent idle with I/O pending

Several other paging-space-related metrics (such as number of forks, read, writes, and execs) are also returned. For a complete list of other paging-space-related metrics, see the perfstat_cpu_total_t section in the libperfstat.h header file.

The following code shows an example of how the perfstat_cpu_total_rset interface is used from the global environment:

(36줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program produces output that is similar to the following output:

text
Number of active logical processors=8
Number of configured processors=8
Processor description=PowerPC_POWER7
Processor speed in Hz=3304000000
Raw total number of clock ticks spent in user mode=86400
Raw total number of clock ticks spent in system mode=30636100
Raw total number of clock ticks spent idle=2826632699
Raw total number of clock ticks spent wait=852000

The following code shows an example of how perfstat_cpu_total_rset is used from the WPAR environment:

(34줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

캐시된 지표 인터페이스

캐시된 지표 인터페이스는 시스템 구성이 바뀌었을 때 libperfstat API에 캐시된 지표를 초기화해야 한다고 알리는 데 씁니다. 캐시된 지표는 디스크 크기나 프로세서 설명처럼 잘 바뀌지 않는 값입니다.

캐시되는 지표는 다음과 같습니다.

객체 내용 값의 예
perfstat_cpu_total char cpu_description[IDENTIFIER_LENGTH], u_longlong_t processorHZ PowerPC_POWER3, 375000000
perfstat_diskadapter 디스크 어댑터 목록, 디스크 어댑터 수, u_longlong_t size, u_longlong_t free, char description[IDENTIFIER_LENGTH] scsi0, scsi1, ide0 / 3 / 17344 / 15296 / Wide/Ultra-3 SCSI I/O Controller
perfstat_pagingspace 페이징 공간 목록, 페이징 공간 수, char automatic, char type, longlong_t lpsize, longlong_t mbsize, char hostname[IDENTIFIER_LENGTH], char filename[IDENTIFIER_LENGTH] hd6 / 1 / 1 / NFS_PAGING / 16 / 512 / pompei 또는 rootvg / /var/tmp/nfsswap/swapfile1
perfstat_disk char adapter[IDENTIFIER_LENGTH], char description[IDENTIFIER_LENGTH], char vgname[IDENTIFIER_LENGTH], u_longlong_t size, u_longlong_t free scsi0 / 16 Bit LVD SCSI Disk Drive / rootvg / 17344 / 15296
perfstat_diskpath char adapter[IDENTIFIER_LENGTH] scsi0
perfstat_netinterface char description[IDENTIFIER_LENGTH] Standard Ethernet Network Interface
perfstat_logicalvolume char description[IDENTIFIER_LENGTH] Logical volume1
perfstat_volumegroup char description[IDENTIFIER_LENGTH] Volume group1

캐시된 지표를 새로 고치는 데 다음 AIX 인터페이스를 쓸 수 있습니다.

인터페이스 용도 정의
perfstat_reset 캐시된 지표를 모두 초기화합니다. void perfstat_reset (void);
perfstat_partial_reset 고른 캐시 지표를 초기화하거나, 시스템의 디스크 최소·최대 카운터를 초기화합니다. void perfstat_partial_reset (char * name, u_longlong_t resetmask);

매개변수 사용법은 다음과 같습니다.

매개변수 설명
char *name libperfstat API 캐시에서 초기화할 캐시 지표의 구성 요소 이름. NULL이면 모든 구성 요소를 뜻합니다.
u_longlong_t resetmask name이 NULL이 아닐 때 구성 요소의 범주. FLUSH_CPUTOTAL, FLUSH_DISK, RESET_DISK_MINMAX, FLUSH_DISKADAPTER, FLUSH_DISKPATH, FLUSH_NETINTERFACE, FLUSH_PAGINGSPACE, FLUSH_LOGICALVOLUME, FLUSH_VOLUMEGROUP 가운데 하나입니다. name이 NULL이면 여러 값을 조합할 수 있습니다. 예: RESET_DISK_MINMAX, FLUSH_CPUTOTAL, FLUSH_DISK를 OR한 값
영어 원문

Cached metrics interfaces

Cached metrics interfaces are used when the system configuration changes to inform the libperfstat API that it must reset cached metrics, which consist of values that seldom change such as disk size or processor description.

The following table lists the metrics that are cached:

Object Content Sample value
perfstat_cpu_total char cpu_description [IDENTIFIER_LENGTH] u_longlong_t processorHZ PowerPC_POWER3375000000
perfstat_diskadapter The list of disk adapters The number of disk adapters u_longlong_t size u_longlong_t free char description [IDENTIFIER_LENGTH] scsi0, scsi1, ide0 3 17344 15296 Wide/Ultra-3 SCSI I/O Controller
perfstat_pagingspace The list of paging spaces The number of paging spaces char automatic char type longlong_t lpsize longlong_t mbsize char hostname [IDENTIFIER_LENGTH] char filename [IDENTIFIER_LENGTH] hd6 1 1 NFS_PAGING 16 512pompei or rootvg /var/tmp/nfsswap/swapfile1
perfstat_disk char adapter [IDENTIFIER_LENGTH] char description [IDENTIFIER_LENGTH] char vgname [IDENTIFIER_LENGTH] u_longlong_t sizeu_longlong_t free scsi0 16 Bit LVD SCSI Disk Drive rootvg 17344 15296
perfstat_diskpath char adapter [IDENTIFIER_LENGTH] scsi0
perfstat_netinterface char description [IDENTIFIER_LENGTH] Standard Ethernet Network Interface
perfstat_logicalvolume char description [IDENTIFIER_LENGTH] Logical volume1
perfstat_volumegroup char description [IDENTIFIER_LENGTH] Volume group1

You can use the following AIX interfaces to refresh the cached metrics:

Interface Purpose Definition of interface
perfstat_reset Resets every cached metric void perfstat_reset (void);
perfstat_partial_reset Resets selected cached metrics or resets the system's minimum and maximum counters for disks void perfstat_partial_reset (char * name, u_longlong_t resetmask);

The usage of the parameters for all of the interfaces is as follows:

  • char *name — Identifies the name of the component of the cached metric that must be reset from the libperfstat API cache. If the value of the parameter is NULL, this signifies all of the components.
  • u_longlong_t resetmask — Identifies the category of the component if the value of the name parameter is not NULL. The possible values are: • FLUSH_CPUTOTAL • FLUSH_DISK • RESET_DISK_MINMAX • FLUSH_DISKADAPTER • FLUSH_DISKPATH • FLUSH_NETINTERFACE • FLUSH_PAGINGSPACE • FLUSH_LOGICALVOLUME • FLUSH_VOLUMEGROUP If the value of the name parameter is NULL, the resetmask parameter value consists of a combination of values. For example: RESET_DISK_MINMAX|FLUSH_CPUTOTAL|FLUSH_DISK

perfstat_reset 인터페이스

perfstat_reset 인터페이스는 libperfstat API가 저장한 캐시 지표를 모두 초기화합니다. 시스템의 디스크·경로 관련 최소·최대 카운터도 초기화합니다. 더 골라서 하려면 perfstat_partial_reset 인터페이스를 쓰는 것이 좋습니다.

영어 원문

The perfstat_reset interface

The perfstat_reset interface resets every cached metric that is stored by the libperfstat API. It also resets the system's minimum and maximum counters related to disks and paths. To be more selective, it is advised to use the perfstat_partial_reset interface.

perfstat_partial_reset 인터페이스

perfstat_partial_reset 인터페이스는 libperfstat API가 저장한 캐시 지표 가운데 지정한 것을 초기화합니다.

perfstat_partial_reset 인터페이스는 시스템의 디스크·경로 관련 최소·최대 카운터도 초기화할 수 있습니다. resetmask 값에 따른 동작은 다음과 같습니다.

resetmask 값 name이 NULL일 때 name이 NULL이 아니고 resetmask 값을 하나만 줄 때
FLUSH_CPUTOTAL perfstat_cputotal_t 구조체의 speed와 description 값을 비웁니다. 오류. errno가 EINVAL로 설정됩니다.
FLUSH_DISK 모든 perfstat_disk_t 구조체의 description, adapter, size, free, vgname 값을 비웁니다. 디스크 어댑터 목록을 비우고, 모든 perfstat_diskadapter_t 구조체의 size, free, description 값을 비웁니다. 지정한 perfstat_disk_t 구조체의 description, adapter, size, free, vgname 값을 비웁니다. 디스크 이름 뒤에 _Path 식별자가 붙은 모든 perfstat_diskpath_t 구조체의 adapter 값을 비웁니다. 그 디스크로 가는 경로나 디스크 자체에 연결된 각 perfstat_diskadapter_t 구조체의 size, free, description 값을 비웁니다.
RESET_DISK_MINMAX 모든 perfstat_diskadapter_t 구조체의 wq_min_time, wq_max_time, min_rserv, max_rserv, min_wserv, max_wserv 값을 초기화합니다. 오류. errno가 ENOTSUP로 설정됩니다.
FLUSH_DISKADAPTER 디스크 어댑터 목록을 비우고, 모든 perfstat_diskadapter_t의 size, free, description, 모든 perfstat_diskpath_t의 adapter, 모든 perfstat_disk_t의 description과 adapter 값을 비웁니다. 왼쪽과 같습니다.
FLUSH_DISKPATH 모든 perfstat_diskpath_t 구조체의 adapter 값을 비웁니다. 지정한 perfstat_diskpath_t 구조체의 adapter 값을 비웁니다.
FLUSH_PAGINGSPACE 페이징 공간 목록을 비우고, 모든 perfstat_pagingspace_t 구조체의 automatic, type, lpsize, mbsize, hostname, filename, vgname 값을 비웁니다. 페이징 공간 목록을 비우고, 지정한 perfstat_pagingspace_t 구조체의 같은 값들을 비웁니다.
FLUSH_NETINTERFACE 모든 perfstat_netinterface_t 구조체의 description 값을 비웁니다. 지정한 perfstat_netinterface_t 구조체의 description 값을 비웁니다.
FLUSH_LOGICALVOLUME 모든 perfstat_logicalvolume_t 구조체의 description 값을 비웁니다. 모든 perfstat_logicalvolume_t 구조체의 description 값을 비웁니다(원문 그대로).
FLUSH_VOLUMEGROUP 모든 perfstat_volumegroup_t 구조체의 description 값을 비웁니다. 모든 perfstat_volumegroup_t 구조체의 description 값을 비웁니다(원문 그대로).

다음 예제 코드에서 perfstat_partial_reset 인터페이스의 사용법을 볼 수 있습니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
int main(int argc, char *argv[]) {
   int i, retcode;
   perfstat_id_t diskname;
   perfstat_disk_t *statp;
   /* set name of the disk */
   strcpy(diskname.name, "hdisk0");
   /* we will now reset global system min/max metrics
    * Be careful as this could interact with other programs.
    */
   perfstat_partial_reset(NULL, RESET_DISK_MINMAX);
   /* min/max values are now reset.
    * We can now wait for some time before checking the variation range.
    */
   sleep(10);
   retcode =  perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0);
   statp = calloc (retcode,sizeof(perfstat_disk_t));
   /* get disk metrics - min/max counters illustrate variations during the
    *                    last 60 seconds unless someone else reset these
    *                    values in the meantime.
    */
   retcode =  perfstat_disk(&diskname, statp, sizeof(perfstat_disk_t), 1);
   /* At this point, we assume the disk free part changes due to chfs for example */
   /* if we get disk metrics here, the free field will be wrong as it was
    * cached by the libperfstat.
    */
   /* That is why we reset cached metrics */
   perfstat_partial_reset("hdisk0", FLUSH_DISK);
   /* we can now get updated disk metrics */
   retcode =  perfstat_disk(&diskname, statp, sizeof(perfstat_disk_t), 1);
   for(i=0;i<retcode;i++){
      printf("Name of the disk=%s\n",statp[i].name);
      printf("Disk description=%s\n",statp[i].description);
      printf("Volume group name=%s\n",statp[i].vgname);
      printf("Size of the disk=%lld\n",statp[i].size);
      printf("Free portion of the disk=%lld\n",statp[i].free);
      printf("Disk block size=%lld\n",statp[i].bsize);
  }
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Name of the disk=hdisk0
Disk description=Virtual SCSI Disk Drive
Volume group name=rootvg
Size of the disk=25568
Free portion of the disk=18752
Disk block size=512
영어 원문

perfstat_partial_reset Interface

The perfstat_partial_reset interface resets the specified cached metrics that are stored by the libperfstat API.

The perfstat_partial_reset interface can also reset the system's minimum and maximum counters related to disks and paths. The following table summarizes the various actions of the perfstat_partial_reset interface:

The resetmask value Action taken when the value of name is NULL Action taken when the value of name is not NULL and a single resetmask value is set FLUSH_CPUTOTAL Flushes the speed and description values in the perfstat_cputotal_t structure. Error. The value of errno is set to EINVAL.

FLUSH_DISK Flushes the description, adapter, size, free, and vgname values in every perfstat_disk_t structure.Flushes the list of disk adapters. Flushes the size, free, and description values in everyperfstat_diskadapter_t structure. Flushes the description, adapter, size, free, and vgname values in the specified perfstat_disk_t structure. Flushes the adapter value in every perfstat_diskpath_t structure that matches the disk name that is followed by the _Path identifier. Flushes the size, free, and description values of each perfstat_diskadapter_t structure that is linked to a path leading to the disk or to the disk itself.

RESET_DISK_MINMAX Resets the following values in every perfstat_diskadapter_t structure:

  • wq_min_time

  • wq_max_time

  • min_rserv

  • max_rserv

  • min_wserv

  • max_wserv Error. The value of errno is set to ENOTSUP.

FLUSH_DISKADAPTER Flushes the list of disk adapters. Flushes the size, free, and description values in every perfstat_diskadapter_t structure. Flushes the adapter value in every perfstat_diskpath_t structure. Flushes the description and adapter values in every perfstat_disk_t structure. Flushes the list of disk adapters. Flushes the size, free, and description values in every perfstat_diskadapter_t structure.Flushes the adapter value in every perfstat_diskpath_t structure. Flushes the description and adapter values in every perfstat_disk_t structure. FLUSH_DISKPATH Flushes the adapter value in every perfstat_diskpath_t structure. Flushes the adapter value in the specified perfstat_diskpath_t structure. FLUSH_PAGINGSPACE Flushes the list of paging spaces. Flushes the automatic, type, lpsize, mbsize, hostname, filename, and vgname values in every perfstat_pagingspace_t structure. Flushes the list of paging spaces. Flushes the automatic, type, lpsize, mbsize, hostname, filename, and vgname values in the specified perfstat_pagingspace_t structure. FLUSH_NETINTERFACE Flushes the description value in every perfstat_netinterface_t structure. Flushes the description value in the specified perfstat_netinterface_t structure. FLUSH_LOGICALVOLUME Flushes the description value in every perfstat_logicalvolume_t structure. Flushes the description value in every perfstat_logicalvolume_t structure. FLUSH_VOLUMEGROUP Flushes the description value in every perfstat_volumegroup_t structure. Flushes the description value in every perfstat_volumegroup_t structure.

You can see how to use the perfstat_partial_reset interface in the following example code:

(41줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

text
Name of the disk=hdisk0
Disk description=Virtual SCSI Disk Drive
Volume group name=rootvg
Size of the disk=25568
Free portion of the disk=18752
Disk block size=512

(6.1) 노드 인터페이스

노드 인터페이스는 클러스터에 있는 원격 노드의 구성 요소 집합이나 개별 구성 요소에 관한 지표를 보고합니다. 구성 요소 집합은 프로세서나 메모리, 개별 구성 요소는 원격 노드의 프로세서, 네트워크 인터페이스, 메모리 페이지 등입니다.

원격 노드는 perfstat API를 쓰는 현재 노드의 클러스터 가운데 하나에 속해야 합니다.

다음 노드 인터페이스는 perfstat_subsystem_node라는 이름 규칙과 공통 형태를 씁니다.

인터페이스 설명
perfstat_cpu_node 원격 노드의 개별 프로세서 사용 지표
perfstat_disk_node 원격 노드의 개별 디스크 사용 지표
perfstat_diskadapter_node 원격 노드의 디스크 어댑터 지표
perfstat_diskpath_node 원격 노드의 디스크 경로 지표
perfstat_logicalvolume_node 원격 노드의 논리 볼륨 사용 지표
perfstat_memory_page_node 원격 노드의 메모리 페이지 크기별 사용 지표
perfstat_netbuffer_node 원격 노드의 네트워크 버퍼 할당 지표
perfstat_netinterface_node 원격 노드의 네트워크 인터페이스 지표
perfstat_pagingspace_node 원격 노드의 페이징 공간 지표
perfstat_protocol_node 원격 노드의 네트워크 프로토콜 관련 지표
perfstat_tape_node 원격 노드의 테이프 사용 지표
perfstat_volumegroup_node 원격 노드의 볼륨 그룹 사용 지표
perfstat_cpu_total_node 원격 노드의 프로세서 사용 요약
perfstat_partition_total_node 원격 노드의 파티션 지표
perfstat_tape_total_node 원격 노드의 테이프 사용 요약
perfstat_memory_total_node 원격 노드의 메모리 사용 요약
perfstat_netinterface_total_node 원격 노드의 네트워크 인터페이스 사용 요약
perfstat_disk_total_node 원격 노드의 디스크 사용 요약

perfstat_memory_page_node 인터페이스를 뺀 perfstat_subsystem_node 인터페이스의 공통 형태는 다음과 같습니다.

text
int perfstat_subsystem_node(perfstat_id_node_t *name,
perfstat_subsystem_t *userbuff,
int sizeof_struct,
int desired_number);

perfstat_memory_page_node 인터페이스의 형태는 다음과 같습니다.

text
int perfstat_memory_page_node(perfstat_id_node_t *name,
perfstat_psize_t *psize;
perfstat_subsystem_t *userbuff,
int sizeof_struct,
int desired_number);

perfstat_subsystem_node 인터페이스의 매개변수 사용법은 다음과 같습니다.

매개변수 설명
perfstat_id_node_t *name 노드 이름을 name->u.nodename 형식으로 지정합니다. name에는 첫 구성 요소 이름이 들어 있어야 합니다. 예를 들어 perfstat_disk_node()이면 통계를 얻을 디스크 이름 hdisk2입니다. 참고: 노드 이름을 지정할 때는 NODENAME으로 초기화해야 합니다.
perfstat_subsystem_t *userbuff 돌려받을 구조체가 들어갈 공간이 충분한 메모리 영역을 가리킵니다.
int sizeof_struct perfstat_subsystem_t의 크기로 설정합니다.
int desired_number userbuff에 돌려받을 perfstat_subsystem_t 구조체 수

perfstat_subsystem_node 인터페이스는 오류면 -1을, 그렇지 않으면 복사한 구조체 수를 돌려줍니다. name 필드는 다음에 쓸 수 있는 구조체의 이름으로 설정됩니다. 예외로 userbuff가 NULL이고 desired_number가 0이면 쓸 수 있는 구조체의 전체 수를 돌려줍니다.

다음 예는 perfstat_disk_node 인터페이스의 사용법입니다.

text
#include <stdio.h>
#include <stdlib.h>
#include <libperfstat.h>
#define INTERVAL_DEFAULT 2
#define COUNT_DEFAULT 10
int main(int argc, char* argv[])
{
    int i, ret, tot;
   int interval = INTERVAL_DEFAULT, count = COUNT_DEFAULT;
   int collect_remote_node_stats = 0;
   char nodename[MAXHOSTNAMELEN];
   perfstat_disk_t *statp;
   perfstat_id_t first;
   perfstat_id_node_t nodeid;
   /* Process the arguments */
   while ((i = getopt(argc, argv, "i:c:n:")) != EOF)
   {
      switch(i)
      {
          case ’i’:/* Interval */
                   interval = atoi(optarg);
                   if( interval <= 0 )
                       interval = INTERVAL_DEFAULT;
                   break;
          case ’c’:/* Number of interations */
                   count = atoi(optarg);
                   if( count <= 0 )
                       count = COUNT_DEFAULT;
                   break;
          case ’n’:/* Node name in a cluster environment */
                   strncpy(nodename, optarg, MAXHOSTNAMELEN);
                   nodename[MAXHOSTNAMELEN-1] = ’\0’;
                   collect_remote_node_stats = 1;
                   break;
          default:
                   /* Invalid arguments. Print the usage and terminate */
                   fprintf (stderr, "usage: %s [-i <interval in seconds>] [-c <number of iterations>] [-n <node name in the cluster>]\n", argv[0]);
      }
   }
   if(collect_remote_node_stats)
   {
       /* perfstat_config needs to be called to enable cluster statistics collection */
       ret = perfstat_config(PERFSTAT_ENABLE|PERFSTAT_CLUSTER_STATS, NULL);
       if (ret == -1)
       {
          perror("cluster statistics collection is not available");
          exit(-1);
       }
   }
   /* check how many perfstat_disk_t structures are available */
   if(collect_remote_node_stats)
   {
       strncpy(nodeid.u.nodename, nodename, MAXHOSTNAMELEN);
       nodeid.spec = NODENAME;
       tot =  perfstat_disk_node(&nodeid, NULL, sizeof(perfstat_disk_t), 0);
   }
   else
   {
       tot =  perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0);
   }
   /* check for error */
   if (tot < 0)
   {
       perror("perfstat_disk");
       exit(-1);
   }
   if (tot == 0)
   {
       printf("No disks found\n");
       exit(-1);
   }
   /* allocate enough memory for all the structures */
   statp = calloc(tot, sizeof(perfstat_disk_t));
   if(statp==NULL){
printf("No sufficient memory\n");
exit(-1);
   }
   if(collect_remote_node_stats)
   {
       /* Remember nodename is already set */
       /* Now set name to first interface */
       strcpy(nodeid.name, FIRST_DISK);
       /* ask to get all the structures available in one call */
       /* return code is number of structures returned */
       ret = perfstat_disk_node(&nodeid, statp,
                           sizeof(perfstat_disk_t), tot);
   }
   else
   {
       /* set name to first interface */
       strcpy(first.name, FIRST_DISK);
       /* ask to get all the structures available in one call */
       /* return code is number of structures returned */
       ret = perfstat_disk(&first, statp,
                           sizeof(perfstat_disk_t), tot);
   }
   /* check for error */
   if (ret <= 0)
   {
       perror("perfstat_disk");
       exit(-1);
   }
    /* print statistics for each of the disks */
    for (i = 0; i < ret; i++) {
        printf("\nStatistics for disk : %s\n", statp[i].name);
        printf("-------------------\n");
        printf("description              : %s\n", statp[i].description);
        printf("volume group name        : %s\n", statp[i].vgname);
        printf("adapter name             : %s\n", statp[i].adapter);
        printf("size                     : %llu MB\n", statp[i].size);
        printf("free space               : %llu MB\n", statp[i].free);
        printf("number of blocks read    : %llu blocks of %llu bytes\n", statp[i].rblks, statp[i].bsize);
        printf("number of blocks written : %llu blocks of %llu bytes\n", statp[i].wblks, statp[i].bsize);
    }
   if(collect_remote_node_stats) {
     /* Now disable cluster statistics by calling perfstat_config */
     perfstat_config(PERFSTAT_DISABLE|PERFSTAT_CLUSTER_STATS, NULL);
   }
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Statistics for disk : hdisk0
----------------------------
description              : Virtual SCSI Disk Drive
volume group name        : rootvg
adapter name             : vscsi0
size                     : 25568 MB
free space               : 19616 MB
number of blocks read    : 315130 blocks of 512 bytes
number of blocks written : 228352 blocks of 512 bytes

다음 프로그램은 vmstat 명령처럼 perfstat_memory_total_node 인터페이스로 원격 노드의 가상 메모리 정보를 가져오는 예입니다.

text
#include <stdio.h>
#include <libperfstat.h>
#define INTERVAL_DEFAULT 2
#define COUNT_DEFAULT 10
int main(int argc, char* argv[])
{
    perfstat_memory_total_t minfo;
    perfstat_id_node_t nodeid;
    char nodename[MAXHOSTNAMELEN];
    int interval = INTERVAL_DEFAULT, count = COUNT_DEFAULT;
    int collect_remote_node_stats = 0;
    int i, rc;
    /* Process the arguments */
    while ((i = getopt(argc, argv, "i:c:n:")) != EOF)
    {
       switch(i)
       {
           case ’i’: /* Interval */
                    interval = atoi(optarg);
                    if( interval <= 0 )
                        interval = INTERVAL_DEFAULT;
                    break;
           case ’c’: /* Number of iterations */
                    count = atoi(optarg);
                    if( count <= 0 )
                        count = COUNT_DEFAULT;
                    break;
           case ’n’: /* Node name in a cluster environment */
                    strncpy(nodename, optarg, MAXHOSTNAMELEN);
                    nodename[MAXHOSTNAMELEN-1] = ’\0’;
                    collect_remote_node_stats = 1;
                    break;
           default:
                   /* Invalid arguments. Print the usage and end */
                   fprintf (stderr, "usage: %s [-i <interval in seconds>] [-c <number of iterations>] [-n <node name in the cluster>]\n", argv[0]);
       }
    }
    if(collect_remote_node_stats)
    {
        /* perfstat_config needs to be called to enable cluster statistics collection */
        rc = perfstat_config(PERFSTAT_ENABLE|PERFSTAT_CLUSTER_STATS, NULL);
        if (rc == -1)
        {
           perror("cluster statistics collection is not available");
           exit(-1);
        }
    }
    if(collect_remote_node_stats)
    {
        strncpy(nodeid.u.nodename, nodename, MAXHOSTNAMELEN);
        nodeid.spec = NODENAME;
        rc = perfstat_memory_total_node(&nodeid, &minfo, sizeof(perfstat_memory_total_t), 1);
    }
    else
    {
        rc = perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
    }
    if (rc != 1) {
        perror("perfstat_memory_total");
        exit(-1);
    }
    printf("Memory statistics\n");
    printf("-----------------\n");
    printf("real memory size                 : %llu MB\n",
           minfo.real_total*4096/1024/1024);
    printf("reserved paging space            : %llu MB\n",minfo.pgsp_rsvd);
    printf("virtual memory size              : %llu MB\n",
           minfo.virt_total*4096/1024/1024);
    printf("number of free pages             : %llu\n",minfo.real_free);
    printf("number of pinned pages           : %llu\n",minfo.real_pinned);
    printf("number of pages in file cache    : %llu\n",minfo.numperm);
    printf("total paging space pages         : %llu\n",minfo.pgsp_total);
    printf("free paging space pages          : %llu\n", minfo.pgsp_free);
    printf("used paging space                : %3.2f%%\n",
        (float)(minfo.pgsp_total-minfo.pgsp_free)*100.0/
        (float)minfo.pgsp_total);
    printf("number of paging space page ins  : %llu\n",minfo.pgspins);
    printf("number of paging space page outs : %llu\n",minfo.pgspouts);
    printf("number of page ins               : %llu\n",minfo.pgins);
    printf("number of page outs              : %llu\n",minfo.pgouts);
    if(collect_remote_node_stats) {
     /* Now disable cluster statistics by calling perfstat_config */
     perfstat_config(PERFSTAT_DISABLE|PERFSTAT_CLUSTER_STATS, NULL);
   }
}

이 프로그램은 다음과 비슷한 출력을 냅니다.

text
Memory statistics
-----------------
real memory size                 : 4096 MB
reserved paging space            : 512 MB
virtual memory size              : 4608 MB
number of free pages             : 768401
number of pinned pages           : 237429
number of pages in file cache    : 21473
total paging space pages         : 131072
free paging space pages          : 128821
used paging space                : 1.72%
number of paging space page ins  : 0
number of paging space page outs : 0
number of page ins               : 37301
number of page outs              : 9692

perfstat_cluster_total 인터페이스는 libperfstat.h 파일에 정의된 perfstat_cluster_total_t 구조체로 클러스터 통계를 가져오는 데 씁니다. 주요 필드는 다음과 같습니다.

필드 설명
name 클러스터 이름
type 클러스터를 나타내는 비트 묶음
num_nodes 클러스터의 노드 수
node_data 모든 노드의 정보를 담은 메모리 영역을 가리킵니다.
num_disks 클러스터의 디스크 수
disk_data 모든 디스크의 정보를 담은 메모리 영역을 가리킵니다.

perfstat_cluster_total_t 구조체의 전체 매개변수 목록은 libperfstat.h 헤더 파일을 봅니다.

다음은 perfstat_cluster_total 인터페이스의 사용 예입니다.

text
#include <stdio.h>
#include <libperfstat.h>
typedef enum {
 DISPLAY_DEFAULT = 0,
 DISPLAY_NODE_DATA = 1,
 DISPLAY_DISK_DATA = 2
} display_t;
int main(int argc, char* argv[])
{
perfstat_cluster_total_t cstats;
perfstat_node_data_t *node_details;
perfstat_disk_data_t *disk_details;
perfstat_id_node_t nodeid;
display_t display = DISPLAY_DEFAULT;
int num_nodes;
int i, rc;
/* Process the arguments */
while ((i = getopt(argc, argv, "lnd")) != EOF)
{
   switch(i)
   {
       case ’n’: /* Request to display node data */
                display |= DISPLAY_NODE_DATA;
                break;
       case ’d’: /* Request to diplay disk data */
                display |= DISPLAY_DISK_DATA;
                break;
       case ’h’: /* Print help message */
       default:
               /* Print the usage and end */
               fprintf (stderr, "usage: %s [-n] [-d]\n", argv[0]);
               exit(-1);
   }
}
/* perfstat_config needs to be called to enable cluster statistics collection */
rc = perfstat_config(PERFSTAT_ENABLE|PERFSTAT_CLUSTER_STATS, NULL);
if (rc == -1)
{
    perror("cluster statistics collection is not available");
    exit(-1);
}
/* Collect cluster statistics */
strncpy(nodeid.u.nodename, FIRST_CLUSTERNAME, MAXHOSTNAMELEN);
nodeid.spec = CLUSTERNAME;
cstats.node_data = NULL;  /* To indicate no interest in node details */
cstats.disk_data = NULL;  /* To indicate no interest in disk details */
rc = perfstat_cluster_total(&nodeid, &cstats, sizeof(perfstat_cluster_total_t), 1);
if (rc == -1)
{
    perror("perfstat_cluster_total failed");
    exit(-1);
}
fprintf(stdout, "Cluster statistics\n");
fprintf(stdout, "------------------\n");
fprintf(stdout, "Cluster Name : %s\n", cstats.name);
fprintf(stdout, "Cluster type : ");
if (cstats.type.b.is_local)
    fprintf(stdout, "LOCAL\n");
else if (cstats.type.b.is_zone)
    fprintf(stdout, "ZONE\n");
else if (cstats.type.b.is_link)
    fprintf(stdout, "LINK\n");
fprintf(stdout, "Number of nodes : %u\n", cstats.num_nodes);
fprintf(stdout, "Number of disks : %u\n", cstats.num_disks);
/* check if the user requested node data */
if(((display & DISPLAY_NODE_DATA) && (cstats.num_nodes > 0)) ||
   ((display & DISPLAY_DISK_DATA) && (cstats.num_disks > 0)))
{
    if(display & DISPLAY_NODE_DATA)
    {
        cstats.sizeof_node_data = sizeof(perfstat_node_data_t);
        /* Make sure you allocate at least cstats.num_nodes */
        /* Otherwise, perfstat_cluster_total() fails with ENOSPC */
        cstats.node_data = (perfstat_node_data_t *) malloc(cstats.sizeof_node_data * cstats.num_nodes);
        if(cstats.node_data == NULL)
        {
            perror("malloc failed for node_data");
            exit(-1);
        }
    }
    if(display & DISPLAY_DISK_DATA)
    {
        cstats.sizeof_disk_data = sizeof(perfstat_disk_data_t);
        /* Make sure you allocate at least cstats.num_disks */
            /* Otherwise, perfstat_cluster_total() fails with ENOSPC */
            cstats.disk_data = (perfstat_disk_data_t *) malloc(cstats.sizeof_disk_data * cstats.num_disks);
            if(cstats.disk_data == NULL)
            {
                perror("malloc failed for disk_data");
                exit(-1);
            }
        }
        rc = perfstat_cluster_total(&nodeid, &cstats, sizeof(perfstat_cluster_total_t), 1);
        if (rc == -1)
        {
            perror("perfstat_cluster_total failed");
            exit(-1);
        }
        if(display & DISPLAY_NODE_DATA)
        {
            fprintf(stdout, "\nNode details:\n");
            fprintf(stdout, "-------------\n");
            node_details = cstats.node_data;
            for (i = 0; i < cstats.num_nodes; i++, node_details++)
            {
                fprintf(stdout, "Node name : %s\n", node_details->name);
                fprintf(stdout, "Node shorthand id : %llu\n",
                        node_details->shorthand_id);
                fprintf(stdout, "Status of the node : ");
                if (node_details->status.b.is_up)
                    fprintf(stdout, "UP\n");
                else if (node_details->status.b.is_down)
                    fprintf(stdout, "DOWN\n");
                fprintf(stdout, "Number of clusters the node is participating : %u\n", node_details->num_clusters);
                fprintf(stdout, "Number of zones the node is participating    : %u\n", node_details->num_zones);
                fprintf(stdout, "Number of points of contact to the node      :%u\n", node_details->num_points_of_contact);
                fprintf(stdout, "\n");
            }
        }
        if(display & DISPLAY_DISK_DATA)
        {
            fprintf(stdout, "\nDisk details:\n");
            fprintf(stdout, "-------------\n");
            disk_details = cstats.disk_data;
            for (i = 0; i < cstats.num_disks; i++, disk_details++)
            {
                fprintf(stdout, "Disk name : %s\n", disk_details->name);
                fprintf(stdout, "Status of the disk :");
                if (disk_details->status.b.is_found)
                {
                    fprintf(stdout, " FOUND");
                    if (disk_details->status.b.is_ready)
                        fprintf(stdout, " | READY");
                    else
                        fprintf(stdout, " | NOT READY");
                }
                else
                    fprintf(stdout, " NOT FOUND");
                fprintf(stdout, "\n");
                fprintf(stdout, "\n");
            }
        }
    }
     /* Now disable cluster statistics by calling perfstat_config */
     perfstat_config(PERFSTAT_DISABLE|PERFSTAT_CLUSTER_STATS, NULL);
}

perfstat_node_list 인터페이스는 libperfstat.h 파일에 정의된 perfstat_node_t 구조체로 노드 목록을 가져오는 데 씁니다. 주요 필드는 다음과 같습니다.

필드 설명
nodeid 노드 식별자
nodename 노드 이름

다음은 perfstat_node_list 인터페이스의 사용 예입니다.

text
#include <stdio.h>
#include <libperfstat.h>
int main(int argc, char* argv[])
{
    perfstat_id_node_t nodeid;
    perfstat_node_t *node_list;
    int num_nodes;
    int i, rc;
    /* perfstat_config needs to be called to enable cluster statistics collection */
    rc = perfstat_config(PERFSTAT_ENABLE|PERFSTAT_CLUSTER_STATS, NULL);
    if (rc == -1)
    {
        perror("cluster statistics collection is not available");
        exit(-1);
    }
    strncpy(nodeid.u.nodename, FIRST_CLUSTERNAME, MAXHOSTNAMELEN);
    nodeid.spec = CLUSTERNAME;
    num_nodes = perfstat_node_list(&nodeid, NULL, sizeof(perfstat_node_t), 0);
    if (num_nodes == -1)
    {
        perror("perfstat_node_list failed");
        exit(-1);
    }
    if (num_nodes == 0)
    {   /* This cannot happen */
        fprintf(stdout, "No nodes in the cluster.\n");
        exit(-1);
    }
    node_list = (perfstat_node_t *) malloc(sizeof(perfstat_node_t) * num_nodes);
    num_nodes = perfstat_node_list(&nodeid, node_list, sizeof(perfstat_node_t), num_nodes);
    if (num_nodes == -1)
    {
        perror("perfstat_node_list failed");
        exit(-1);
    }
    fprintf(stdout, "Number of nodes : %d\n\n", num_nodes);
    for (i = 0; i < num_nodes; i++)
    {
        fprintf(stdout, "Node name : %s\n", node_list[i].nodename);
        fprintf(stdout, "Node id : %llu\n", node_list[i].nodeid);
        fprintf(stdout, "\n");
    }
    /* Now disable cluster statistics by calling perfstat_config */
    perfstat_config(PERFSTAT_DISABLE|PERFSTAT_CLUSTER_STATS, NULL);
     return (0);
}

perfstat_cluster_disk 인터페이스는 perfstat_disk_data_t 구조체로 디스크 목록을 가져오는 데 씁니다. perfstat_cluster_disk 인터페이스는 libperfstat.h 파일에 정의되어 있습니다.

다음은 perfstat_cluster_disk 서브루틴의 사용 예입니다.

text
#include <stdio.h>
#include <libperfstat.h>
typedef enum {
 DISPLAY_NODE_DATA = 1,
 DISPLAY_DISK_DATA = 2,
} display_t;
int main(int argc, char* argv[])
{
 perfstat_node_data_t *node_details;
 perfstat_disk_data_t *disk_details;
 perfstat_id_node_t nodeid;
 char nodename[MAXHOSTNAMELEN];
    display_t display = DISPLAY_DISK_DATA;
 int num_nodes;
 int i, rc, num_of_disks = 0;
 /* Process the arguments */
 while ((i = getopt(argc, argv, "n:d")) != EOF)
 {
  switch(i)
  {
   case ’n’:               /* Request to display node data */
    display |= DISPLAY_NODE_DATA;
    strncpy(nodename,optarg,MAXHOSTNAMELEN);
    break;
   case ’d’:               /* Request to diplay disk data */
    display |= DISPLAY_DISK_DATA;
    break;
   case ’h’:               /* Print help message */
   default:
    /* Print the usage and terminate */
    fprintf (stderr, "usage: %s [-n <nodename>] [-d]\n", argv[0]);
    exit(-1);
  }
 }
 /* perfstat_config needs to be called to enable cluster statistics collection */
 rc = perfstat_config(PERFSTAT_ENABLE|PERFSTAT_CLUSTER_STATS, NULL);
 if (rc == -1)
 {
  perror("cluster statistics collection is not available");
  exit(-1);
 }
 /*If Node details are specified pass that data as input to get the disk details
   for that node . Else pass FIRST_NODENAME */
 if (display & DISPLAY_NODE_DATA)
 {
  strncpy(nodeid.u.nodename,nodename,MAXHOSTNAMELEN);
 }
 else
  strncpy(nodeid.u.nodename, FIRST_NODENAME, MAXHOSTNAMELEN);
 nodeid.spec = NODENAME;
 /*Get the number of disks for that node */
 num_of_disks = perfstat_cluster_disk(&nodeid,NULL, sizeof(perfstat_disk_data_t), 0);
 if (num_of_disks == -1)
 {
  perror("perfstat_cluster_disk failed");
  exit(-1);
 }
 disk_details = (perfstat_disk_data_t *)calloc(num_of_disks,sizeof(perfstat_disk_data_t));
 /* collect all the disk data for the node */
 if(!disk_details){
  perror("calloc");
 exit(-1);
 }
 num_of_disks = perfstat_cluster_disk(&nodeid,disk_details,sizeof(perfstat_disk_data_t),num_of_disks);
 fprintf(stdout, "Disk Details\n");
 fprintf(stdout, "------------------\n");
 for(i = 0; i < num_of_disks; i++)
 {
  fprintf(stdout,"Disk Name:%s\t UDID:%s\n",disk_details[i].name,disk_details[i].uuid);
 }
 /* Now disable cluster statistics by calling perfstat_config */
 perfstat_config(PERFSTAT_DISABLE|PERFSTAT_CLUSTER_STATS, NULL);
 free(disk_details);
 disk_details = NULL;
}
영어 원문

Node interfaces

Node interfaces report metrics related to a set of components or individual components of a remote node in the cluster. The components include processors or memory, and individual components include a processor, network interface, or memory page of the remote node in the cluster.

The remote node must belong to one of the clusters of the current node, which uses the perfstat API.

The following node interfaces use theperfstat_subsystem_node as the naming convention and a common signature:

  • perfstat_cpu_node — Retrieves the usage metrics of an individual processor on a remote node.
  • perfstat_disk_node — Retrieves the usage metrics of an individual disk on a remote node.
  • perfstat_diskadapter_node — Retrieves the adapter metrics of a disk on a remote node.
  • perfstat_diskpath_node — Retrieves the path metrics of a disk on a remote node.
  • perfstat_logicalvolume_node — Retrieves the usage metrics of a logical volume on a remote node.
  • perfstat_memory_page_node — Retrieves the usage metrics of a memory page size on a remote node.
  • perfstat_netbuffer_node — Retrieves the buffer allocation metrics of a network on a remote node.
  • perfstat_netinterface_node — Retrieves the interface metrics of a network on a remote size node.
  • perfstat_pagingspace_node — Retrieves the space metrics of a page on a remote node.
  • perfstat_protocol_node — Retrieves the protocol-related metrics of a network on a remote node.
  • perfstat_tape_node — Retrieves the usage metrics of a tape on a remote node.
  • perfstat_volumegroup_node — Retrieves the usage metrics of a volume group on a remote node.
  • perfstat_cpu_total_node — Retrieves the summary on the usage metrics of a processor on a remote node.
  • perfstat_partition_total_node — Retrieves the partition metrics on a remote node.
  • perfstat_tape_total_node — Retrieves the summary on the usage metrics of a tape on a remote node.
  • perfstat_memory_total_node — Retrieves the summary on the usage metrics of a memory on a remote node.
  • perfstat_netinterface_total_node — Retrieves the summary on the usage metrics of a network interface on a remote node.
  • perfstat_disk_total_node — Retrieves the summary on the usage metrics of a disk on a remote node.

The following common signature is used by the perfstat_subsystem_node interface except the

perfstat_memory_page_node interface

text
int perfstat_subsystem_node(perfstat_id_node_t *name,
perfstat_subsystem_t *userbuff,
int sizeof_struct,
int desired_number);

The following signature is used by the perfstat_memory_page_node interface:

text
int perfstat_memory_page_node(perfstat_id_node_t *name,
perfstat_psize_t *psize;
perfstat_subsystem_t *userbuff,
int sizeof_struct,
int desired_number);

The following table describes the usage of the parameters of the perfstat_subsystem_node interface:

  • perfstat_id_node_t *name — Specify the name of the node in name->u.nodenameformat. The name must contain the name of the first component. For example, hdisk2 for perfstat_disk_node(), where hdisk 2 is the name of the disk for which you require the statistics. Note: When you specify a nodename, it must be initialized as NODENAME.
  • perfstat_subsystem_t *userbuff — Points to a memory area that has enough space for the returned structure.
  • int sizeof_struct — Sets this parameter to the size of perfstat_subsystem_t.
  • int desired_number — Specifies the number of structures of type perfstat_subsystem_t to return to a userbuff field.

The perfstat_subsystem_node interface return -1 value for error. Otherwise it returns the number of structures copied. The field namename is set to the name of the next available structure, and an exceptional case when userbuff equals NULL and desired_number equals 0, the total number of structures available is returned.

The following example shows the usage of the perfstat_disk_node interface:

(119줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

text
Statistics for disk : hdisk0
----------------------------
description              : Virtual SCSI Disk Drive
volume group name        : rootvg
adapter name             : vscsi0
size                     : 25568 MB
free space               : 19616 MB
number of blocks read    : 315130 blocks of 512 bytes
number of blocks written : 228352 blocks of 512 bytes

The following program shows the usage of the vmstat command and an example of using the perfstat_memory_total_node interface to retrieve the virtual memory details of the remote node:

(85줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The program displays an output that is similar to the following example output:

(15줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The perfstat_cluster_total interface is used to retrieve cluster statistics from the perfstat_cluster_total_t structure, which is defined in the libperfstat.h file. The following selected fields are from the perfstat_cpu_total_t structure:

  • name — Specifies the name of the cluster.
  • Type — Specifies the set of bits that describes the cluster.
  • num_nodes — Specifies the number of nodes in the cluster.
  • node_data — Points to a memory area that describes the details of all the nodes.
  • num_disks — Specifies the number of disks in the cluster.
  • disk_data — Points to a memory area that describes the details of all the disks.

For a complete list of parameters related to the perfstat_cluster_total_t structure, see the libperfstat.h header file.

The following code example shows the usage of the perfstat_cluster_total interface:

(146줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The perfstat_node_list interface is used to retrieve the list of nodes in the perfstat_node_t structure, which is defined in the libperfstat.h file. The following selected fields are from the perfstat_node_t structure:

  • nodeid — Specifies the identifier of the node.
  • nodename — Specifies the name of the node.

The following code example shows the usage of theperfstat_node_list interface:

(46줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The perfstat_cluster_disk interface is used to retrieve the list of disks in the perfstat_disk_data_t structure. The perfstat_cluster_disk interface is defined in the libperfstat.h file.

The following example code shows the usage of the perfstat_cluster_disk subroutine:

(75줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

perfstat API의 변경 이력

perfstat API에 다음과 같은 변경과 추가가 있었습니다.

영어 원문

Change history of the perfstat API

The following changes and additions have been made to the perfstat APIs.

인터페이스 변경

다음 파일 세트부터 perfstat_disk_total_t, perfstat_diskadapter_t, perfstat_diskpath_t 구조체의 rblks와 wblks 필드는, 지표를 가져오는 장치가 실제로 쓰는 블록 크기와 상관없이 512바이트 블록 단위로 나타냅니다.

  • bos.perf.libperfstat 4.3.3.4
  • bos.perf.libperfstat 5.1.0.50
  • bos.perf.libperfstat 5.2.0.10
영어 원문

Interface changes

With the following filesets the rblks and wblks fields of libperfstat are represented by blocks of 512 bytes in the perfstat_disk_total_t, perfstat_diskadapter_t and perfstat_diskpath_t structures, regardless of the actual block size used by the device for which metrics are being retrieved.

  • bos.perf.libperfstat 4.3.3.4

  • bos.perf.libperfstat 5.1.0.50

  • bos.perf.libperfstat 5.2.0.10

인터페이스 추가

파일 세트 수준마다 더해진 인터페이스입니다.

파일 세트 수준 더해진 인터페이스
bos.perf.libperfstat 5.2.0 perfstat_netbuffer, perfstat_protocol, perfstat_pagingspace, perfstat_diskadapter, perfstat_reset
bos.perf.libperfstat 5.2.0.10 perfstat_diskpath
bos.perf.libperfstat 5.3.0.0 perfstat_partition_total
bos.perf.libperfstat 5.3.0.10 perfstat_partial_reset
(6.1) bos.perf.libperfstat 6.1.2 perfstat_cpu_total_wpar, perfstat_memory_total_wpar, perfstat_cpu_total_rset, perfstat_cpu_rset, perfstat_wpar_total, perfstat_tape, perfstat_tape_total, perfstat_memory_page, perfstat_memory_page_wpar, perfstat_logicalvolume, perfstat_volumegroup, perfstat_config
(6.1) bos.perf.libperfstat 6.1.6.0 perfstat_cpu_node, perfstat_disk_node, perfstat_diskadapter_node, perfstat_diskpath_node, perfstat_logicalvolume_node, perfstat_memory_page_node, perfstat_netbuffer_node, perfstat_netinterface_node, perfstat_protocol_node, perfstat_volumegroup_node, perfstat_cpu_total_node, perfstat_disk_total_node, perfstat_memory_total_node, perfstat_netinterface_total_node, perfstat_partition_total_node, perfstat_tape_total_node, perfstat_cluster_total, perfstat_node_list
(6.1) bos.perf.libperfstat 6.1.7.0 perfstat_hfistat, perfstat_hfistat_window
영어 원문

Interface additions

Review the specific interfaces that are available for a fileset.

The following interfaces were added in the bos.perf.libperfstat 5.2.0 file set:

  • perfstat_netbuffer

  • perfstat_protocol

  • perfstat_pagingspace

  • perfstat_diskadapter

  • perfstat_reset

The perfstat_diskpath interface was added in the bos.perf.libperfstat 5.2.0.10 file set.

The perfstat_partition_total interface was added in the bos.perf.libperfstat 5.3.0.0 file set.

Theperfstat_partial_reset interface was added in the bos.perf.libperfstat 5.3.0.10 file set.

The following interfaces were added in the bos.perf.libperfstat 6.1.2 file set:

  • perfstat_cpu_total_wpar

  • perfstat_memory_total_wpar

  • perfstat_cpu_total_rset

  • perfstat_cpu_rset

  • perfstat_wpar_total

  • perfstat_tape

  • perfstat_tape_total

  • perfstat_memory_page

  • perfstat_memory_page_wpar

  • perfstat_logicalvolume

  • perfstat_volumegroup

  • perfstat_config

The following interfaces were added in thebos.perf.libperfstat 6.1.6.0 file set:

  • perfstat_cpu_node

  • perfstat_disk_node

  • perfstat_diskadapter_node

  • perfstat_diskpath_node

  • perfstat_logicalvolume_node

  • perfstat_memory_page_node

  • perfstat_netbuffer_node

  • perfstat_netinterface_node

  • perfstat_protocol_node

  • perfstat_volumegroup_node

  • perfstat_cpu_total_node

  • perfstat_disk_total_node

  • perfstat_memory_total_node

  • perfstat_netinterface_total_node

  • perfstat_partition_total_node

  • perfstat_tape_total_node

  • perfstat_cluster_total

  • perfstat_node_list

The following interfaces were added in thebos.perf.libperfstat 6.1.7.0 file set:

  • perfstat_hfistat

  • perfstat_hfistat_window

필드 추가

파일 세트 수준마다 다음이 더해졌습니다.

bos.perf.libperfstat 5.1.0.15 파일 세트

perfstat_cpu_total_t에 더해진 필드입니다.

text
u_longlong_t bread
u_longlong_t bwrite
u_longlong_t lread
u_longlong_t lwrite
u_longlong_t phread
u_longlong_t phwrite

이 수준에서 C++ 지원이 더해졌습니다.

bos.perf.libperfstat 5.1.0.25 파일 세트

perfstat_cpu_t에 더해진 필드입니다.

text
u_longlong_t bread
u_longlong_t bwrite
u_longlong_t lread
u_longlong_t lwrite
u_longlong_t phread
u_longlong_t phwrite

bos.perf.libperfstat 5.2.0 파일 세트

perfstat_cpu_t에 더해진 필드입니다.

text
u_longlong_t iget
u_longlong_t namei
u_longlong_t dirblk
u_longlong_t msg
u_longlong_t sema

논리 프로세서 이름을 돌려주는 name 필드는 이전 릴리스의 proc0, proc1 대신 cpu0, cpu1 형식이 되었습니다.

perfstat_cpu_total_t에 더해진 필드입니다.

text
u_longlong_t runocc
u_longlong_t swpocc
u_longlong_t iget
u_longlong_t namei
u_longlong_t dirblk
u_longlong_t msg
u_longlong_t sema
u_longlong_t rcvint
u_longlong_t xmtint
u_longlong_t mdmint
u_longlong_t tty_rawinch
u_longlong_t tty_caninch
u_longlong_t tty_rawoutch
u_longlong_t ksched
u_longlong_t koverf
u_longlong_t kexit
u_longlong_t rbread
u_longlong_t rcread
u_longlong_t rbwrt
u_longlong_t rcwrt
u_longlong_t traps
int ncpus_high

perfstat_disk_t에 더해진 필드입니다.

text
char adapter[IDENTIFIER_LENGTH]

perfstat_netinterface_t에 더해진 필드입니다.

text
u_longlong_t bitrate

perfstat_memory_total_t에 더해진 필드입니다.

text
u_longlong_t real_system
u_longlong_t real_user
u_longlong_t real_process

libperfstat.h에 더해진 정의입니다.

text
#define FIRST_CPU          ""
#define FIRST_DISK         ""
#define FIRST_DISKADAPTER  ""
#define FIRST_NETINTERFACE ""
#define FIRST_PAGINGSPACE  ""
#define FIRST_PROTOCOL     ""
#define FIRST_ALLOC        ""

bos.perf.libperfstat 5.2.0.10 파일 세트

perfstat_disk_t에 더해진 필드입니다.

text
uint paths_count

libperfstat.h에 더해진 정의입니다.

text
#define FIRST_DISKPATH  ""

bos.perf.libperfstat 5.3.0.0 파일 세트

perfstat_cpu_t에 더해진 필드입니다.

text
u_longlong_t puser
u_longlong_t psyss
u_longlong_t pidle
u_longlong_t pwait
u_longlong_t redisp_sd0
u_longlong_t redisp_sd1
u_longlong_t redisp_sd2
u_longlong_t redisp_sd3
u_longlong_t redisp_sd4
u_longlong_t redisp_sd5
u_longlong_t migration_push
u_longlong_t migration_S3grq
u_longlong_t migration_S3pul
u_longlong_t invol_cswitch
u_longlong_t vol_cswitch
u_longlong_t runque
u_longlong_t bound
u_longlong_t decrintrs
u_longlong_t mpcrintrs
u_longlong_t mpcsintrs
u_longlong_t devintrs
u_longlong_t softintrs
u_longlong_t phantintrs

perfstat_cpu_total_t에 더해진 필드입니다.

text
u_longlong_t puser
u_longlong_t psys
u_longlong_t pidle
u_longlong_t pwait
u_longlong_t decrintrs
u_longlong_t mpcrintrs
u_longlong_t mpcsintrs
u_longlong_t phantintrs

bos.perf.libperfstat 5.3.0.10 파일 세트

perfstat_disk_t와 perfstat_diskpath_t에 모두 더해진 필드입니다.

text
u_longlong_t  q_full
u_longlong_t  rserv
u_longlong_t  rtimeout
u_longlong_t  rfailed
u_longlong_t  min_rserv
u_longlong_t  max_rserv
u_longlong_t  wserv
u_longlong_t  wtimeout
u_longlong_t  wfailed
u_longlong_t  min_wserv
u_longlong_t  max_wserv
u_longlong_t  wq_depth
u_longlong_t  wq_sampled
u_longlong_t  wq_time
u_longlong_t  wq_min_time
u_longlong_t  wq_max_time
u_longlong_t  q_sampled

또 다음 데이터 구조의 xrate 필드는 이름이 __rxfers로 바뀌었으며, 일부 장치 드라이버와 쓰면 읽기 트랜잭션 수를, 아니면 0을 담습니다.

text
perfstat_disk_t
perfstat_disk_total_t
perfstat_diskadapter_t
perfstat_diskpath_t

libperfstat.h 헤더 파일에 더해진 정의입니다.

text
#define FLUSH_CPUTOTAL
#define FLUSH_DISK
#define RESET_DISK_MINMAX
#define FLUSH_DISKADAPTER
#define FLUSH_DISKPATH
#define FLUSH_PAGINGSPACE
#define FLUSH_NETINTERFACE

bos.perf.libperfstat 5.3.0.50 파일 세트

perfstat_partition_total_t에 더해진 필드입니다.

text
u_longlong_t reserved_pages
u_longlong_t reserved_pagesize

bos.perf.libperfstat 5.3.0.60 파일 세트

perfstat_cpu_t, perfstat_cpu_total_t, perfstat_partition_total_t에 더해진 필드입니다.

text
u_longlong_t idle_donated_purr
u_longlong_t idle_donated_spurr
u_longlong_t busy_donated_purr
u_longlong_t busy_donated_spurr
u_longlong_t idle_stolen_purr
u_longlong_t idle_stolen_spurr
u_longlong_t busy_stolen_purr
u_longlong_t busy_stolen_spurr

perfstat_partition_type_t에 더해진 플래그입니다.

text
unsigned donate_capable
unsigned donate_enabled

(6.1) bos.perf.libperfstat 6.1.6.0 파일 세트

기존의 모든 인터페이스에 다음 필드가 더해졌습니다.

text
u_longlong_t version
영어 원문

Field additions

The following additions have been made to the specified file set levels.

The bos.perf.libperfstat 5.1.0.15 file set

The following fields were added to perfstat_cpu_total_t:

text
u_longlong_t bread
u_longlong_t bwrite
u_longlong_t lread
u_longlong_t lwrite
u_longlong_t phread
u_longlong_t phwrite

Support for C++ was added in this file set level.

The bos.perf.libperfstat 5.1.0.25 file set

The following fields were added to perfstat_cpu_t:

text
u_longlong_t bread
u_longlong_t bwrite
u_longlong_t lread
u_longlong_t lwrite
u_longlong_t phread
u_longlong_t phwrite

The bos.perf.libperfstat 5.2.0 file set

The following fields were added to perfstat_cpu_t:

text
u_longlong_t iget
u_longlong_t namei
u_longlong_t dirblk
u_longlong_t msg
u_longlong_t sema

The name field which returns the logical processor name is now of the form cpu0, cpu1, instead of proc0, proc1 as it was in previous releases.

The following fields were added to perfstat_cpu_total_t:

(22줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The following field was added to perfstat_disk_t:

text
char adapter[IDENTIFIER_LENGTH]

The following field was added to perfstat_netinterface_t:

text
u_longlong_t bitrate

The following fields were added to perfstat_memory_total_t:

text
u_longlong_t real_system
u_longlong_t real_user
u_longlong_t real_process

The following defines were added to libperfstat.h:

text
#define FIRST_CPU          ""
#define FIRST_DISK         ""
#define FIRST_DISKADAPTER  ""
#define FIRST_NETINTERFACE ""
#define FIRST_PAGINGSPACE  ""
#define FIRST_PROTOCOL     ""
#define FIRST_ALLOC        ""

The bos.perf.libperfstat 5.2.0.10 file set

The following field was added to the perfstat_disk_t interface:

text
uint paths_count

The following define was added to libperfstat.h:

text
#define FIRST_DISKPATH  ""

The bos.perf.libperfstat 5.3.0.0 file set

The following fields were added to the perfstat_cpu_t interface:

(23줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

The following fields were added to the perfstat_cpu_total_t interface:

text
u_longlong_t puser
u_longlong_t psys
u_longlong_t pidle
u_longlong_t pwait
u_longlong_t decrintrs
u_longlong_t mpcrintrs
u_longlong_t mpcsintrs
u_longlong_t phantintrs

The bos.perf.libperfstat 5.3.0.10 file set

The following fields were added to both the perfstat_disk_t and perfstat_diskpath_t interfaces:

(17줄짜리 예는 위 한글 본문에 그대로 실었습니다.)

In addition, the xrate field in the following data structures has been renamed to _rxfers and contains the number of read transactions when used with selected device drivers or zero:

text
perfstat_disk_t
perfstat_disk_total_t
perfstat_diskadapter_t
perfstat_diskpath_t

The following definitions were added to the libperfstat.h header file:

text
#define FLUSH_CPUTOTAL
#define FLUSH_DISK
#define RESET_DISK_MINMAX
#define FLUSH_DISKADAPTER
#define FLUSH_DISKPATH
#define FLUSH_PAGINGSPACE
#define FLUSH_NETINTERFACE

The bos.perf.libperfstat 5.3.0.50 file set

The following fields were added to perfstat_partition_total_t:

text
u_longlong_t reserved_pages
u_longlong_t reserved_pagesize

The bos.perf.libperfstat 5.3.0.60 file set

The following fields were added to perfstat_cpu_t, perfstat_cpu_total_t and perfstat_partition_total_t:

text
u_longlong_t idle_donated_purr
u_longlong_t idle_donated_spurr
u_longlong_t busy_donated_purr
u_longlong_t busy_donated_spurr
u_longlong_t idle_stolen_purr
u_longlong_t idle_stolen_spurr
u_longlong_t busy_stolen_purr
u_longlong_t busy_stolen_spurr

The following flags were added to perfstat_partition_type_t:

text
unsigned donate_capable
unsigned donate_enabled

The bos.perf.libperfstat 6.1.6.0 file set

The following field is added to all existing interfaces:

text
u_longlong_t version

구조체 추가

파일 세트 수준마다 더해진 구조체입니다.

(6.1) bos.perf.libperfstat 6.1.2.0 파일 세트에서 더해진 구조체입니다.

text
perfstat_cpu_total_wpar_t
perfstat_cpu_total_rset_t
perfstat_cpu_rset_t
perfstat_wpar_total_t
perfstat_tape_t
perfstat_tape_total_t
perfstat_memory_page_t
perfstat_memory_page_wpar_t
perfstat_logicalvolume_t
perfstat_volumegroup_t

(6.1) bos.perf.libperfstat 6.1.6.0 파일 세트에서 더해진 구조체입니다.

text
perfstat_id_node_t
perfstat_node_t
perfstat_cluster_total_t
perfstat_cluster_type_t
perfstat_node_data_t
perfstat_disk_data_t
perfstat_disk_status_t
perfstat_ip_addr_t

(6.1) bos.perf.libperfstat 6.1.7.0 파일 세트에서 더해진 구조체입니다.

text
perfstat_hfistat_t
perfstat_hfistat_window_t
영어 원문

Structure additions

Review the specific structure additions that are available for different file sets.

The following structures are added in the bos.perf.libperfstat 6.1.2.0 file set:

text
perfstat_cpu_total_wpar_t
perfstat_cpu_total_rset_t
perfstat_cpu_rset_t
perfstat_wpar_total_t
perfstat_tape_t
perfstat_tape_total_t
perfstat_memory_page_t
perfstat_memory_page_wpar_t
perfstat_logicalvolume_t
perfstat_volumegroup_t

The following structures are added in the bos.perf.libperfstat 6.1.6.0 file set:

text
perfstat_id_node_t
perfstat_node_t
perfstat_cluster_total_t
perfstat_cluster_type_t
perfstat_node_data_t
perfstat_disk_data_t
perfstat_disk_status_t
perfstat_ip_addr_t

The following structures are added in the bos.perf.libperfstat 6.1.7.0 file set:

text
perfstat_hfistat_t
perfstat_hfistat_window_t