[AIX 성능 도구 19] RSI(원격 통계 인터페이스) API
https://archive.horanglab.com/posts/aix-perf-rsi
핵심 정리
- RSI는 하나 이상의
xmtopas데몬(perfagent)이 제공하는 통계를 받는 데이터 소비자 프로그램을 만드는 C API입니다(-lSpmi -lbsd,-D_AIX -D_BSD). 예제는/usr/samples/perfmgr에 있습니다. - 기본 흐름:
RSiInitx→RSiOpenx(호스트 연결, 콜백 지정) →RSiPathGetCxx·RSiFirstStatx·RSiNextStatx(통계 찾기) →RSiCreateStatSetx·RSiPathAddSetStatx(statset) →RSiStartFeedx→RSiMainLoopx(data_feed가 오면 콜백,RSiGetValuex로 값 읽기) →RSiClosex. - 통계는
hosts/호스트/CPU/cpu0같은 문맥(context) 경로로 찾습니다. hotset은 가장 바쁜(또는 한가한) 동료 통계 몇 개만 받는 방식입니다. - 오류는 외부 정수
RSiErrno(RSiOkay,RSiTimeout280 …RSiNotSupported300)로 확인합니다. 데몬이 다시 살아나면i_am_back패킷으로 재동기화 콜백이 불립니다. Rsi.hosts파일로 방송(broadcast) 대상, 직접 연결할 호스트(nobroadcast), 통신 포트 범위(portrange 3001 3003)를 정합니다. 문자 화면 예제 모니터는chmon입니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 6.1 (5.3판 Performance Tools Guide에는 이 장이 없음) |
| 원문 | Performance Tools Guide and Reference — 6.1판 348~362쪽 |
| 파일 | /usr/include/sys/Rsi.h, /usr/include/sys/Spmidef.h, /usr/samples/perfmgr, $HOME/Rsi.hosts, /etc/perf/Rsi.hosts |
| 관련 명령어 | xmtopas, xmperf, chmon, topas |
원격 통계 인터페이스(Remote Statistics Interface, RSI)는 하나 이상의 xmtopas 데몬이 제공하는 통계에 접근하는 프로그램을 만드는 데 쓰는 응용 프로그래밍 인터페이스(API)입니다.
예제 프로그램으로 RSI API 쓰는 법을 배웁니다. 예제 프로그램은 /usr/samples/perfmgr 디렉터리에 있습니다.
RSI API로 하나 이상의 xmtopas 데몬에 접근하는 프로그램을 만듭니다. xmtopas 데몬이 주는 원래 통계를 출력하거나 나중에 처리하거나 그 밖의 방식으로 다루는 프로그램을 만들 수 있으며, 이런 프로그램을 데이터 소비자(Data-Consumer) 프로그램이라고 합니다. RSI 서브루틴 설명을 보려면 AIX Technical Reference: Communications, Volume 2가 설치되어 있어야 합니다(원문은 Version 7.1이라고 적음).
영어 원문
Remote Statistics Interface API Overview
The Remote Statistics Interface (RSI) is an application programming interface (API) that is available for developing programs that access the statistics available from one or more xmtopas daemons.
Learn the procedure to use the RSI Interface API through the sample programs. The sample programs, and others, are also provided in the machine-readable. The sample programs can be found in the /usr/samples/perfmgr directory.
Use the RSI Interface API to write programs that access one or more xmtopas daemons. It allows you to develop programs that print, post-process, or otherwise manipulate the raw statistics provided by the xmtopas daemons. Such programs are known as Data-Consumer programs. AIX Version 7.1 Technical Reference: Communications, Volume 2 must be installed to see the RSi subroutines
Makefile
포함(include) 파일은 define 지시자를 바탕으로 하므로 알맞게 설정해야 합니다. 전처리기 플래그 -D로 정의합니다.
_AIX: 포함 파일이 AIX용 코드를 만들게 합니다._BSD: BSD 호환성에 필요합니다.
예제 프로그램을 빌드하는 Makefile의 예입니다.
LIBS = -L./ -lbsd -lSpmi
CC = cc
CFLAGS = -D_BSD -DRSIv6 -D_AIX ®
all:: RsiCons RsiCons1 chmon
RsiCons: RsiCons.c
$(CC) -o RsiCons RsiCons.c $(CFLAGS) $(LIBS)
RsiCons1: RsiCons1.c
$(CC) -o RsiCons1 RsiCons1.c $(CFLAGS) $(LIBS)
chmon: chmon.c $
$(CC) -o chmon chmon.c $(CFLAGS) $(LIBS) -lcurses
컴파일하는 시스템이 ANSI 함수 원형을 지원하지 않으면 -D_NO_PROTO 플래그를 넣습니다.
영어 원문
Makefile
The include files are based on the define directives, which must be properly set. They are defined with the -D preprocessor flag.
_AIX®specifies the include files to generate code for AIX._BSDrequired for proper BSD compatibility.
An example of a Makefile that helps to build a sample program follows:
LIBS = -L./ -lbsd -lSpmi
CC = cc
CFLAGS = -D_BSD -DRSIv6 -D_AIX ®
all:: RsiCons RsiCons1 chmon
RsiCons: RsiCons.c
$(CC) -o RsiCons RsiCons.c $(CFLAGS) $(LIBS)
RsiCons1: RsiCons1.c
$(CC) -o RsiCons1 RsiCons1.c $(CFLAGS) $(LIBS)
chmon: chmon.c $
$(CC) -o chmon chmon.c $(CFLAGS) $(LIBS) -lcurses
If the system that is used to compile does not support ANSI function prototypes, include the -D_NO_PROTO flag.
RSI 서브루틴 목록
xmperf 인터페이스는 네트워크의 모든 호스트의 통계를 그래픽으로 보는 데 씁니다.
RSI API는 어떤 호스트의 xmtopas 데몬이든 그 통계에 접근하는 데이터 소비자 프로그램을 만드는 데 씁니다.
RSI 인터페이스는 다음 서브루틴 묶음으로 이루어집니다.
영어 원문
Remote Statistics Interface list of subroutines
The xmperf interface is used to view the graphical display of statistics on all the hosts in a network.
The Remote Statistics Interface (RSI) application programming interface (API) is used to create data-consumer programs that helps to access statistics of any host's xmtopas daemon.
The RSI interface consists of the following groups of subroutines.
초기화와 종료
| 서브루틴 | 설명 |
|---|---|
RSiInitx |
RSI 핸들 표를 할당하거나 바꿉니다. |
RSiOpenx |
원격 호스트에 대한 RSI 인터페이스를 초기화합니다. |
RSiClosex |
원격 호스트에 대한 RSI 인터페이스를 끝내고 할당한 메모리를 모두 해제합니다. |
RSiInvitex |
네트워크의 데이터 공급자에게 스스로를 알리도록 요청하고 데이터 공급자 호스트 이름 표를 돌려줍니다. |
영어 원문
Initialization and Termination
- RSiInitx — Allocates or changes the table of RSI handles.
- RSiOpenx — Initializes the RSI interface for a remote host.
- RSiClosex — Terminates the RSI interface for a remote host and releases all memory allocated.
- RSiInvitex — Invites data suppliers on the network to identify themselves and returns a table of data-supplier host names.
문맥 계층의 인스턴스화와 순회
| 서브루틴 | 설명 |
|---|---|
RSiInstantiatex |
문맥 객체의 모든 하위 문맥을 만듭니다(인스턴스화). |
RSiPathGetCxx |
문맥 경로 이름과 맞는 문맥을 문맥 계층에서 찾습니다. |
RSiFirstCxx |
문맥의 첫 하위 문맥을 돌려줍니다. |
RSiNextCxx |
문맥의 다음 하위 문맥을 돌려줍니다. |
RSiFirstStatx |
문맥의 첫 통계를 돌려줍니다. |
RSiNextStatx |
문맥의 다음 통계를 돌려줍니다. |
영어 원문
Instantiation and Traversal of Context Hierarchy
- RSiInstantiatex — Creates (instantiates) all subcontexts of a context object.
- RSiPathGetCxx — Searches the context hierarchy for a context that matches a context path name.
- RSiFirstCxx — Returns the first subcontext of a context.
- RSiNextCxx — Returns the next subcontext of a context.
- RSiFirstStatx — Returns the first statistic of a context.
- RSiNextStatx — Returns the next statistic of a context.
받을 통계 묶음 정의
| 서브루틴 | 설명 |
|---|---|
RSiAddSetHotx |
hotset에 동료(peer) 통계 묶음 하나를 더합니다. |
RSiCreateHotSetx |
빈 hotset을 만듭니다. |
RSiCreateStatSetx |
빈 statset을 만듭니다. |
RSiPathAddSetStatx |
statset에 통계 하나를 더합니다. |
RSiDelSetHotx |
hotset에서 동료 통계 묶음 하나를 지웁니다. |
RSiDelSetStatx |
statset에서 통계 하나를 지웁니다. |
RSiStatGetPathx |
SpmiStatVals 포인터로 식별한 통계의 전체 경로 이름을 찾습니다. |
영어 원문
Defining Sets of Statistics to Receive
- RSiAddSetHotx — Adds a single set of peer statistics to a hotset.
- RSiCreateHotSetx — Creates an empty hotset.
- RSiCreateStatSetx — Creates an empty statset.
- RSiPathAddSetStatx — Adds a single statistic to a statset.
- RSiDelSetHotx — Deletes a single set of peer statistics from a hotset.
- RSiDelSetStatx — Deletes a single statistic from a statset.
- RSiStatGetPathx — Finds the full path name of a statistic identified by an
SpmiStatValspointer.
데이터 공급 시작·변경·중지
| 서브루틴 | 설명 |
|---|---|
RSiStartFeedx |
statset의 데이터 공급(data feed)을 보내기 시작하라고 xmtopas에 알립니다. |
RSiStartHotFeedx |
hotset의 hot feed를 보내기 시작하라고 xmtopas에 알립니다. |
RSiChangeFeedx |
statset의 데이터 공급 간격을 바꾸라고 xmtopas에 알립니다. |
RSiChangeHotFeedx |
hotset의 hot feed 간격을 바꾸라고 xmtopas에 알립니다. |
RSiStopFeedx |
statset의 데이터 공급을 멈추라고 xmtopas에 알립니다. |
RSiStopHotFeedx |
hotset의 hot feed를 멈추라고 xmtopas에 알립니다. |
영어 원문
Starting, Changing, and Stopping Data Feeding
- RSiStartFeedx — Tells xmtopas to start sending data feeds for a statset.
- RSiStartHotFeedx — Tells xmtopas to start sending hot feeds for a hotset.
- RSiChangeFeedx — Tells xmtopas to change the time interval between sending data feeds for a statset.
- RSiChangeHotFeedx — Tells xmtopas to change the time interval between sending hot feeds for a hotset.
- RSiStopFeedx — Tells xmtopas to stop sending data feeds for a statset.
- RSiStopHotFeedx — Tells xmtopas to stop sending hot feeds for a hotset.
데이터 공급 패킷 받기와 해석
| 서브루틴 | 설명 |
|---|---|
RSiGetHotItemx |
데이터 공급 패킷에서 꺼내 첫(다음) SpmiHotItems 요소의 동료 문맥 이름과 데이터 값을 돌려줍니다. |
RSiMainLoopx |
응용 프로그램이 실행을 멈추고 데이터 공급이 도착하면 깨어나도록 기다리게 합니다. |
RSiGetValuex |
데이터 공급 패킷에서 꺼내, 주어진 SpmiStatVals 포인터의 데이터 값을 돌려줍니다. |
RSiGetRawValuex |
데이터 공급 패킷에서 꺼내, 주어진 SpmiStatVals 포인터에 대한 올바른 SpmiStatVals 구조체의 포인터를 돌려줍니다. |
영어 원문
Receiving and Decoding Data Feed Packets
- RSiGetHotItemx — Returns the peer context name and data value for the first (next) SpmiHotItems element by extraction from data feed packet.
- RSiMainLoopx — Allows an application to suspend execution and waits to be woken when data feeds arrive.
- RSiGetValuex — Returns data value for a given SpmiStatVals pointer by extraction from data feed packet.
- RSiGetRawValuex — Returns a pointer to a valid SpmiStatVals structure for a given SpmiStatVals pointer by extraction from data feed packet.
RSI 인터페이스의 개념과 용어
라이브러리 함수의 구조와 공통점, 중요한 설계 개념입니다.
RSI API를 쓰려면 RSI 인터페이스 자료 구조의 형식과 쓰임을 알아야 합니다.
영어 원문
RSI Interface Concepts and Terms
Learn about the structures and the commonalities of the library functions and important design concepts.
To start using the RSI interface API you must be aware of the format and use of the RSI interface data structures.
RSI 인터페이스 자료 구조
RSI 인터페이스는 원격 호스트의 통계를 지금 어떻게 보고 있는지와, 데이터 소비자 프로그램과 원격 호스트의 xmtopas 데몬 사이 상호 작용의 상태를 나타내는 제어 블록(자료 구조)을 바탕으로 합니다.
RSI 인터페이스는 다음 자료 구조를 지원합니다.
- RSI 핸들
SpmiStatVals
RSI 핸들
RSI 핸들은 RsiHandleStructx 형 자료 구조의 포인터입니다. 다른 RSI 호출을 쓰기 전에 데이터 소비자 프로그램은 RSiInit 서브루틴으로 RSI 핸들 표를 할당해야 합니다. 호스트에 논리 연결을 열면 표의 RSI 핸들 하나가 초기화되며, 같은 호스트에 대한 이후 모든 서브루틴에 그 핸들을 인수로 줘야 합니다. 데이터 소비자 프로그램이 써야 할 RSI 핸들의 내부 필드는 받은 네트워크 패킷의 포인터 pi 하나뿐입니다. 이 포인터가 필요한 경우는 아주 특별한 경우뿐이며, RSiOpenx가 초기화하고 데이터 소비자 프로그램은 절대 바꾸면 안 됩니다. 프로그램이 RSI 핸들 구조체의 필드를 바꾸면 결과를 전혀 예측할 수 없습니다. RSI 핸들은 /usr/include/sys/Rsi.h에 정의되어 있습니다.
SpmiStatVals
데이터 값 하나는 /usr/include/sys/Spmidef.h에 struct SpmiStatVals로 정의된 구조체로 나타냅니다. 응용 프로그램은 이 구조체의 어떤 필드도 바꾸면 안 됩니다. 구조체의 두 핸들은 문맥과 통계를 가리키는 기호 참조이며 포인터와 혼동하면 안 됩니다. 마지막 세 필드는 data_feed 패킷을 받을 때마다 갱신됩니다.
| 필드 | 설명 |
|---|---|
val |
통계 데이터 필드의 최신 실제 내용 |
val_change |
통계 데이터 필드의 최신 실제 내용과 이전에 관찰한 값의 차이(변화량) |
error |
/usr/include/sys/Spmidef.h 파일의 enum Error에 정의된 오류 코드 |
참고: 두 값 필드는 union Value로 정의되어 있어, 해당 SpmiStat 구조체의 플래그에 따라 실제 데이터 필드가 long일 수도 float일 수도 있습니다. SpmiStat 구조체는 StatVals 구조체에서 바로 접근할 수 없습니다(앞서 말했듯 포인터가 올바르지 않음). 그래서 val과 val_change 필드의 데이터 형을 알려면 RSiPathAddSetStatx 서브루틴이 돌려준 SpmiStat 구조체를 저장해 두어야 합니다. 이는 번거로우므로 RSiGetValuex 서브루틴이 모두 대신해 주며, SpmiStat 구조체를 따로 관리하지 않아도 됩니다.
SpmiStat 구조체는 통계 하나를 설명하며 /usr/include/sys/Spmidef.h 파일에 SpmiStat 구조체 형으로 정의되어 있습니다. (RSiStatGetPathx 서브루틴이 돌려주는 정보 말고) 이 자료 구조의 정보가 필요하면 RSiPathAddSetStatx 서브루틴이 돌려준 것을 꼭 저장해 둡니다.
RSiGetValuex 서브루틴으로도 SpmiStat 구조체에 접근할 수 있지만, 데이터 공급 패킷을 처리하는 동안에만 됩니다.
xmtopas 데몬은 동시에 꺼내 한 데이터 패킷으로 데이터 소비자 프로그램에 보낼 통계 묶음의 정의를 받습니다. 이런 통계 묶음을 나타내는 구조체는 /usr/include/sys/Spmidef.h 파일에 SpmiStatSet 구조체 형으로 정의되어 있습니다. RSiCreateStatSetx가 돌려준 SpmiStatSet 포인터는, 다른 여러 서브루틴에 올바른 통계 묶음을 알려 주는 것만이 목적인 핸들로 다뤄야 합니다.
데이터 공급 패킷으로 돌아올 때 SpmiStatSet 구조체에는 (원격 호스트의 시계 기준) 데이터 공급 패킷을 만든 실제 시각과, 같은 SpmiStatSet의 바로 앞 데이터 공급 패킷 이후 경과 시간이 들어 있습니다.
SpmiHotSet 구조체는 지표를 꺼내 처리하는 다른 방식을 정의할 수 있게 하는 접근 구조체 묶음입니다. 동료 문맥 묶음에서 가장 활발하거나 가장 한가한 통계의 데이터 값을 꺼내는 데 씁니다. 예를 들어 가장 부하가 큰 디스크 두 개의 정보를, 선택에 따라 부하가 지정한 임계값을 넘을 때만 받겠다고 정의할 수 있습니다.
SPMI가 SpmiHotSet의 읽기 요청을 받으면 hotset 안의 모든 동료 통계 묶음의 최신 값을 한 번에 읽습니다. 그래서 커널 구조와 다른 시스템 영역에 접근하는 부하가 줄고, hotset 안의 모든 동료 통계 값을 같은 때에 읽게 됩니다. hotset은 동료 통계 묶음 하나나 여럿으로 이루어집니다.
SpmiHotVals
hotset에 고른 동료 통계 묶음마다 SpmiHotVals 구조체가 하나씩 만들어집니다. SPMI가 응용 프로그램의 hotset 데이터 값 읽기 요청을 실행하면 묶음의 모든 SpmiHotVals 구조체가 갱신됩니다. 응용 프로그램은 RSiGetHotItemx 서브루틴으로 SpmiHotVals 구조체 목록을 돌 수 있습니다.
SpmiHotVals 구조체는 SPMI에서 응용 프로그램으로 데이터 값을 나릅니다. 데이터를 나르는 필드는 다음과 같습니다.
| 필드 | 설명 |
|---|---|
error |
SPMI가 마지막으로 동료 통계 묶음의 데이터 값을 읽는 데 성공했으면 0, 아니면 sys/Spmidef.h에 정의된 오류 코드 |
avail_resp |
선택 기준(임계값)을 만족하는 동료 통계 데이터 값의 수. 실제로 돌려주는 항목 수의 최대는 max_responses 필드가 정합니다. |
count |
items 배열로 돌려준 요소 수. 선택 기준(임계값)을 만족한 데이터 값 수이며 max_responses가 상한입니다. |
items |
count개 요소를 돌려주는 배열. SpmiHotItems 자료 구조로 정의되며, 각 요소에는 다음 필드가 있습니다. name: 값을 돌려준 동료 문맥의 이름. val: 동료 통계의 카운터나 수준 필드 값. 원래 공급자가 관리하는 값이지만 SPMI 데이터 형식으로 바뀝니다. val_change: 통계가 카운터 데이터면 이전 읽기와 현재 읽기의 차이. 이 값을 SpmiHotSet 구조체가 돌려준 경과 시간으로 나누면 단위 시간당 이벤트율을 구할 수 있습니다. |
영어 원문
RSI Interface data structures
The RSI interface is based upon control blocks (data structures) that describe the current view of the statistics on a remote host and the state of the interaction between a data consumer program and the remote host's xmtopas daemon.
The RSI interface supports the following data structures:
RSI handle
SpmiStatVals
RSI handle
An RSI handle is a pointer to a data structure of type RsiHandleStructx. Prior to using any other RSI call, a data-consumer program must use the RSiInit subroutine to allocate a table of RSI handles. An RSI handle from the table is initialized when you open the logical connection to a host and that RSI handle must be specified as an argument on all subsequent subroutines to the same host. Only one of the internal fields of the RSI handle should be used by the data-consumer program, namely the pointer to received network packets, pi. Only in very special cases will you ever need to use this pointer, which is initialized by RSiOpenx and must never be modified by a data-consumer program. If your program changes any field in the RSI handle structure, results are highly unpredictable. The RSI handle is defined in /usr/include/sys/Rsi.h.
SpmiStatVals
A single data value is represented by a structure defined in /usr/include/sys/Spmidef.h as struct SpmiStatVals. Be aware that none of the fields defined in the structure must be modified by application
programs. The two handles in the structure are symbolic references to contexts and statistics and should not be confused with pointers. The last three fields are updated whenever a data_feed packet is received. These fields are as follows:
- val — The latest actual contents of the statistics data field.
val_change— The difference (delta value) between the latest actual contents of the statistics data field and the previous value observed.- error — An error code as defined by the
enumError in included in the/usr/include/sys/Spmidef.hfile. - Note: The two value fields are defined as union Value, which means that the actual data fields may be
long or float, depending on flags in the corresponding SpmiStat structure. The SpmiStat structure cannot be accessed directly from the StatVals structure (the pointer is not valid, as previously mentioned). Therefore, to determine the type of data in the val and val_change fields, you must have saved the SpmiStat structure as returned by the RSiPathAddSetStatx subroutine. This is rather clumsy, so the RSiGetValuex subroutine does everything for you and you do not need to keep track of SpmiStat structures.
The SpmiStat structure is used to describe a statistic. It is defined in the /usr/include/sys/Spmidef.h file of type SpmiStat struct . If you ever need information from this data structure (apart from information that can be returned by the RSiStatGetPathx subroutine) be sure to save it as it is returned by the RSiPathAddSetStatx subroutine.
The RSiGetValuex subroutine provides another way of getting access to an SpmiStat structure but can only do so while a data feed packet is being processed.
The xmtopas daemon accepts the definition of sets of statistics that are to be extracted simultaneously and sent to the data-consumer program in a single data packet. The structure that describes such a set of statistics is defined in the /usr/include/sys/Spmidef.h file of type SpmiStatSet struct . As returned by the RSiCreateStatSetx, the SpmiStatSet pointer must be treated as a handle whose only purpose is to identify the correct set of statistics to several other subroutines.
When returned in a data feed packet, the SpmiStatSet structure holds the actual time the data feed packet was created (according to the remote host's clock) and the elapsed time since the latest previous data feed packet for the same SpmiStatSet was created.
SpmiHotSet structure represents another set of access structures that allow an application program to define an alternative way of extracting and processing metrics. They are used to extract data values for the most or least active statistics for a group of peer contexts. For example, it can be used to define that the program wants to receive information about the two highest loaded disks, optionally subject to the load exceeding a specified threshold.
When the SPMI receives a read request for an SpmiHotSet, the SPMI reads the latest value for all the peer sets of statistics in the hotset in one operation. This action reduces the system overhead caused by access of kernel structures and other system areas, and ensures that all data values for the peer sets of statistics within a hotset are read at the same time. The hotset may consist of one or many sets of peer statistics.
SpmiHotVals One SpmiHotVals structure is created for each set of peer statistics selected for the hotset. When the SPMI executes a request from the application program to read the data values for a hotset, all SpmiHotVals structures in the set are updated. The RSi application program can then traverse the list of SpmiHotVals structures by using the RSiGetHotItemx subroutine call.
The SpmiHotVals structure carries the data values from the SPMI to the application program. Its data carrying fields are:
- error — Returns a zero value if the SPMI's last attempt to read the data values for a set of peer statistics was successful. Otherwise, this field contains an error code as defined in the
sys/Spmidef.hfile. avail_resp— Used to return the number of peer statistic data values that meet the selection criteria (threshold). The fieldmax_responsesdetermines the maximum number of entries actually returned.- count — Contains the number of elements returned in the array items. This number is the number of data values that met the selection criteria (threshold), capped at
max_responses. - items — The array used to return count elements. This array is defined in the
SpmiHotItemsdata structure. Each element in theSpmiHotItemsarray has the following fields:nameThe name of the peer context for which the values are returned.valReturns the value of the counter or level field for the peer statistic. This field returns the statistic's value as maintained by the original supplier of the value. However, thevalfield is converted to an SPMI data format.val_changeReturns the difference between the previous reading of the counter and the current reading when the statistic contains counter data. When this value is divided by the elapsed time returned in theSpmiHotSetStructure, an event rate-per-time-unit can be calculated.
RSI 요청-응답 인터페이스
RSI API는 서로 아주 다른 두 방식으로 동작합니다.
RSI 요청-응답 프로토콜은 xmtopas 데몬에 요청 하나를 보내고 응답을 기다립니다. 정한 시간 안에 응답이 없으면 시간 초과가 되고 한 번 다시 시도합니다. 다시 시도해도 시간 초과면 외부 정수 RSiErrno에 RSiTimeout 상수를 넣어 호출자에게 알립니다. 다른 오류가 나면 이 외부 정수 필드에 0이 아닌 다른 값이 들어갑니다.
통신 오류도 시간 초과도 없으면, RSI 핸들의 pi 포인터가 가리키는 수신 버퍼에 패킷이 있습니다. 패킷에는 서브루틴이 xmtopas 데몬에서 성공했는지를 나타내는 상태 코드가 들어 있습니다. 상태 코드가 정확히 무엇인지가 중요하면 패킷의 상태 코드를 확인해야 합니다. 프로그램에는 나쁜 상태 코드를 받았다는 것만 RSiErrno의 RSiBadStat 상수로 알려 주기 때문입니다.
서브루틴의 성공 여부는 서브루틴마다 정의된 오류·성공 표시로 판단하거나, 외부 정수 RSiErrno를 확인합니다. 이 값이 RSiOkay면 성공, 아니면 실패입니다. RSiErrno로 돌려주는 오류 코드는 RSiErrorType 열거형에 정의되어 있습니다.
RSiMainLoop(네트워크 구동 인터페이스를 씀)와 RSiInitx, RSiGetValuex, RSiGetRawValuex(네트워크 통신이 없음)를 빼고 모든 라이브러리 함수는 요청-응답 인터페이스를 씁니다.
영어 원문
RSI Request-Response Interface
The RSI interface API has two distinctly different ways of operation.
The RSI request-response protocol that sends a single request to xmtopas daemon and waits for a response. A timeout occurs if no response has been received within a specified time limit and a single retry is attempted. If the retry also results in a timeout, the same is communicated to the caller by placing the RSiTimeout constant in the external integer RSiErrno field . If any other error occurred, the external integer field has some other non-zero value.
If neither a communication error nor a timeout error occurred, a packet is available in the receive buffer pointed to by the pi pointer in the RSI handle. The packet includes a status code that tells whether the subroutine was successful at the xmtopas daemon. You must check the status code in a packet if it matters what exactly it is because the RSiBadStat constant is placed in RSiErrno field to indicate to your program that a bad status code was received.
You can use the indication of error or success as defined for each subroutine to determine if the subroutine succeeded or you can test the external integer RSiErrno. If this field is RSiOkay the subroutine succeeded; otherwise it did not. The error codes returned in RSiErrno are defined in the RSiErrorType enum .
All the library functions use the request-response interface, except for RSiMainLoop (which uses a network driven interface) and RSiInitx, RSiGetValuex, and RSiGetRawValuex (that do not involve network traffic).
RSI 네트워크 구동 인터페이스
xmquery 프로토콜은 xmtopas 데몬의 데이터 공급자가 요청 패킷 없이 보내는 데이터 패킷 세 종류를 정의합니다.
패킷 종류는 still_alive, data_feed, except_rec입니다. still_alive 패킷은 RSI 인터페이스 안에서 처리되므로 데이터 소비자 프로그램에서 따로 프로그래밍할 것이 없습니다.
data_feed 패킷은 요청-응답 서브루틴이 만드는 패킷과 비동기로 도착합니다. 요청-응답 함수를 처리하는 중에 data_feed 패킷을 받으면 제어가 콜백 함수로 넘어가며, 이 함수는 RSiOpenx 서브루틴으로 RSI 핸들을 초기화할 때 지정해야 합니다.
데이터 소비자 프로그램이 요청-응답 함수를 쓰지 않을 때도 data_feed 패킷을 받아 처리할 수 있어야 합니다. 이는 패킷을 받을 때마다 콜백 함수를 부르는 RSiMainLoopx 함수로 합니다.
실제로 데이터 공급 콜백 함수는 가장 최근에 보낸 요청의 응답으로 알아볼 수 없는 모든 패킷에 대해 불립니다. 다만 i_am_back, still_alive, except_rec 유형은 예외입니다. 곧 시간 초과 뒤에 도착한 요청-응답 패킷의 응답도 콜백 함수로 보내집니다. 받은 패킷의 유형을 확인하는 것은 콜백 함수의 책임입니다.
except_rec 패킷도 요청-응답 서브루틴이 만드는 패킷과 비동기로 도착합니다. 요청-응답 함수를 처리하는 중에 except_rec 패킷을 받으면 제어가 콜백 함수로 넘어가며, 이 함수도 RSiOpenx로 RSI 핸들을 초기화할 때 지정해야 합니다.
요청-응답 함수를 쓰지 않을 때도 except_rec 패킷을 받아 처리할 수 있어야 하며, 이것도 패킷을 받을 때마다 콜백 함수를 부르는 RSiMainLoopx 함수로 합니다.
참고: 그 호스트에 대한 RSiOpenx 호출에서 이 메시지 유형을 처리할 콜백 함수를 지정하지 않으면 API는 원격 호스트의 except_rec 메시지를 버립니다.
영어 원문
RSI Network driven interface
The xmquery protocol defines three types of data packets that are sent from the data supplier of the xmtopas daemon without being solicited by a request packet.
The request packet types are the still_alive, the data_feed, and the except_rec packets. The still_alive packets are handled internally in the RSI interface and require no programming in the data-consumer program.
The data_feed packets are received asynchronously with any packets produced by the request-response type subroutines. If a data_feed packet is received when processing a request-response function, control is passed to a callback function, which must be named when the RSI handle is initialized with the RSiOpenx subroutine.
When the data-consumer program is not using the request-response functions, it still needs to be able to receive and process data_feed packets. This is done with the RSiMainLoopx function, which invokes the callback function whenever a packet is received.
Actually, the data feed callback function is invoked for all packets received that cannot be identified as a response to the latest request sent, except if such packets are of type i_am_back, still_alive, or except_rec. Note that this means that responses to “request-response” packets that arrive after a timeout is sent to the callback function. It is the responsibility of your callback function to test for the packet type received.
The except_rec packets are received asynchronously with any packets produced by the request-response type subroutines. If an except_rec packet is received when processing a request-response function, control is passed to a callback function, which must be named when the RSI handle is initialized with the RSiOpenx subroutine.
When the data-consumer program is not using the request-response functions, it still needs to be able to receive and process except_rec packets. This is done with the RSiMainLoopx function which invokes the callback function whenever a packet is received.
Note: The API discards except_rec messages from a remote host unless a callback function to process the message type was specified on the RSiOpenx subroutine call for that host.
재동기화
네트워크 연결은 끊길 수 있고, 호스트는 내려갈 수 있고, 인터페이스는 꺼질 수 있고, 프로세스는 멈출 수 있습니다.
xmtopas 프로토콜에서 이런 상황은 보통 다음 가운데 하나 이상으로 나타납니다.
- 패킷 분실
- 재동기화 요청
패킷 분실
보낸 요청의 응답을 받지 못해 시간 초과가 생깁니다. 데이터 소비자 프로그램은 어차피 다른 오류 반환 코드도 처리해야 하므로 다루기 쉽습니다. 기대한 데이터 공급도 받지 못하게 되므로 프로그램에서 이를 확인할 수 있습니다. 이 상황의 올바른 처리는 RSiClosex 함수로 죽은 호스트에 관련된 메모리를 모두 해제하고 RSI 핸들을 풀어 주는 것입니다. 그다음 데이터 소비자 프로그램은 원격 시스템에 다시 RSiOpenx를 시도하거나 그냥 끝날 수 있습니다.
재동기화 요청
xmtopas 데몬은 어떤 호스트의 데이터 소비자 프로그램에서 처음 연락을 받으면 i_am_back 유형의 패킷으로 응답해 데이터 소비자 프로그램이 데몬과 재동기화하도록 합니다. 또 데몬이 죽거나 끝났을 때 이야기하던 데이터 소비자 프로그램에 다시 연결하려 할 때도 i_am_back 패킷을 보냅니다.
xmtopas 데몬이 "처음 연락"을 어떻게 판단하는지 이해하는 것이 중요합니다. 판단은 데몬 내부의 표, 곧 데몬이 아는 모든 데이터 소비자를 식별하는 표를 바탕으로 합니다. 데이터 소비자 프로그램은 그것이 실행되는 호스트 이름 뒤에 데몬과 이야기하는 IP 포트 번호를 붙인 것으로 식별됩니다. 실행 중인 데이터 소비자 프로그램은 같은 프로그램을 여러 개 실행해도 각각 유일하게 식별됩니다.
데이터 소비자 프로그램이 정상적으로 끝나면 끝내겠다고 데몬에 알리고, 데몬은 그것을 내부 표에서 지웁니다. 그러나 데이터 소비자 프로그램이 한동안 데이터 공급을 요청하지 않으면, 데몬은 그 소비자가 관심을 잃었다고 판단해 표에서 지웁니다(Life and Death of xmtopas 참고). 나중에 데이터 소비자 프로그램이 다시 xmtopas 데몬과 이야기하려 하면 데몬은 i_am_back 패킷으로 응답합니다.
RSI 인터페이스는 i_am_back 패킷을 특별히 다룹니다. 받을 때마다 재동기화 콜백 함수를 부르며, 이 함수는 RSiOpenx 서브루틴에서 지정해야 합니다.
참고: 원격 xmtopas는 처음에 데이터 소비자를 모르므로, 모든 데이터 소비자 프로그램은 RSiOpenx 서브루틴을 실행하는 동안 이 콜백이 한 번 불린다고 예상할 수 있습니다. 정상이므로 놀랄 필요가 없습니다. RSiOpenx 함수를 처리하는 동안 재동기화 콜백이 두 번 불리면 열기가 실패한 것이며, 알맞으면 다시 시도할 수 있습니다.
영어 원문
Resynchronizing
Network connections can go bad, hosts can go down, interfaces can be taken down and processes can stop functioning.
In the case of the xmtopas protocol, such situations usually result in one or more of the following:
Missing packets
Resynchronizing requests
Missing packets
Responses to outstanding requests are not received, which generate a timeout. That's fairly easy to cope with because the data-consumer program has to handle other error return codes anyway. It also results in expected data feeds not being received. Your program may want to test for this happening. The proper way to handle this situation is to use the RSiClosex function to release all memory related to the dead host and to free the RSI handle. After this is done, the data-consumer program may attempt another RSiOpenx to the remote system or may simply exit.
Resynchronizing requests
Whenever an xmtopas daemon hears from a given data-consumer program on a particular host for the first time, it responds with a packet of i_am_back type, effectively prompting the data-consumer program to resynchronize with the daemon. Also, when the daemon attempts to reconnect to data-consumer programs that it talked to when it was killed or died, it sends an i_am_back packet.
It is important that you understand how the xmtopas daemon handles “first time contacted.” It is based upon tables internal to the daemon. Those tables identify all the data-consumers that the daemon knows about. Be aware that a data-consumer program is known by the host name of the host where it executes suffixed by the IP port number used to talk to the daemon. Each data-consumer program running is identified uniquely as are multiple running copies of the same data-consumer program.
Whenever a data-consumer program exits orderly, it alerts the daemon that it intends to exit and the daemon removes it from the internal tables. If, however, the data-consumer program decides to not request data feeds from the daemon for some time, the daemon detects that the data consumer has lost interest and removes the data consumer from its tables as described in Life and Death of xmtopas. If the data-consumer program decides later that it wants to talk to the xmtopas daemon again, the daemon responds with an i_am_back packet.
The i_am_back packets are given special treatment by the RSI interface. Each time one is received, a resynchronizing callback function is invoked. This function must be defined on the RSiOpenx subroutine.
Note: All data-consumer programs can expect to have this callback invoked once during execution of the RSiOpenx subroutine because the remote xmtopas does not know the data consumer. This is usual and should not cause your program to panic. If the resynchronize callback is invoked twice during processing of the RSiOpenx function, the open failed and can be retried, if appropriate.
RSI 통신의 포트 범위 정하기
xmtopas 인터페이스와 소비자 사이에는 임의의 통신 포트가 필요합니다. Rsi.hosts 구성 파일로 포트를 지정한 범위 안에서 쓰게 할 수 있습니다.
포트 범위를 정하려면 다음과 같이 합니다.
$HOME이나/etc/perf디렉터리에서Rsi.hosts파일을 찾습니다. 두 디렉터리에 없으면/usr/lpp/perfmgr디렉터리에서 찾습니다.Rsi.hosts파일에 허용할 범위의 시작 포트와 끝 포트를 적습니다.Rsi.hosts파일을 찾을 수 없거나 포트 범위를 잘못 적으면 RSI 통신은 임의의 포트를 씁니다.
Rsi.hosts 파일에 포트 범위를 적는 형식은 다음과 같습니다.
portrange <start_port> <end_port>
예:
portrange 3001 3003
RSI 통신이 시작되면 지정한 범위의 3001, 3002, 3003 포트를 씁니다. RSI 에이전트는 3개까지만 포트에서 기다릴 수 있고, 그 뒤의 RSI 통신은 실패합니다.
영어 원문
Specifying port range for RSI communication
A random communication port is required between the xmtopasor xmtopas interface and the consumers. The Rsi.hosts configuration file is used to set the ports within a specified range.
To set the port range, complete these steps:
Locate the
Rsi.hostsfile in the$HOMEor the/etc/perfdirectory. If the file does not exist in either of the directories, search the file in the/usr/lpp/perfmgrdirectory.Specify the start and the end port in the acceptable range as mentioned in the
Rsi.hostsfile. If theRsi.hostsfile cannot be located in directories or the port range is specified incorrectly, the RSI communication uses random ports.
To specify the port range in the Rsi.hosts file, use the following command:
portrange <start_port> <end_port>
Example:
portrange 3001 3003
When the RSI communication starts, it uses 3001, 3002 or 3003 ports in the specified range. Only 3 RSI agents can listen to the ports and the subsequent RSI communication fails.
간단한 데이터 소비자 프로그램
호스트의 통계를 계속 나열하는 작은 데이터 소비자 프로그램을 만들며 API 사용법을 보여 줍니다.
첫 버전은 CPU 관련 통계만 다룹니다. 명령줄에 호스트 이름을 주지 않으면 로컬 호스트의 통계를 가져온다고 가정합니다. 프로그램은 끝낼 때까지 통계를 계속 보여 줍니다. 예제 프로그램의 소스 코드는 /usr/samples/perfmgr/RsiCons1.c 파일에 있습니다.
영어 원문
A Simple Data-Consumer Program
The use of the application programming interface (API) is illustrated by creating a small data-consumer program to produce a continuous list of statistics from a host.
The first version accesses only CPU-related statistics. It assumes that you want to get your statistics from the local host unless you specify a host name on the command line. The program continues to display the statistics until it is killed. The source code for the sample program can be found in the /usr/samples/perfmgr/RsiCons1.c file.
프로그램 초기화와 종료
예제 프로그램의 main 함수는 다음 코드처럼 세 서브루틴을 씁니다. 1215줄은 uname 함수로 얻은 기본 호스트 이름 대신 명령줄 인수를 씁니다. 1728줄은 RSiInitx와 RSiOpenx 서브루틴으로 RSI 인터페이스를 초기화하며, 초기화에 실패하면 프로그램이 끝납니다.
[01] extern char RSiEMsg[];
[02] extern int RSiErrno;
[03] char host[64], apath[256], head1[24][10], head2[24][10];
[04] char *nptr, **navn = &nptr, *dptr, **desc = &dptr;
[05] struct utsname uname_struct;
[07] RsiHandlex rsh;
[08] struct SpmiStatVals *svp[24];
[09] int lct = 99, tix = 0;
[10] [11] main(int argc, char **argv)
[12] {
[13] uname(&uname_struct);
[14] strcpy(host, uname_struct.nodename);
[15] if (argc > 1)
[16] strcpy(host, argv[1]);
[17] if (!(rsh = RsiInitx(1)))
[18] {
[19] fprintf(stderr, “Unable to initialize RSI interface\n”);
[20] exit(98);
[21] }
[22] if (RSiOpenx(rsh, 100, 2048, host, feeding, resync, NULL))
[23] {
[24] if (strlen(RSiEMsg))
[25] fprintf(stderr, “%s”, RSiEMsg);
[26] fprintf(stderr, “Error contacting host\”%s\“\n”, host);
[27] exit(-99);
[28] }
[29] signal(SIGINT, must_exit);
[30] signal(SIGTERM, must_exit);
[31] signal(SIGSEGV, must_exit);
[32] signal(SIGQUIT, must_exit);
[33]
[34] strcpy(apath, “hosts/”);
[35] strcat(apath, host);
[36] strcat(apath, “/”);
[37] lststats(apath);
[38] RSiClosex(rsh);
[39] exit(0);
[40] } The following lines (29-32) make sure that the program detects any attempt to kill or terminate it.
If this happens, the function must_exit is invoked. This function has the sole purpose of making sure the
association with the xmtopas daemon is terminated. It does this as shown in the following piece of code:
void must_exit() { RSiClosex(rsh); exit(-9); }
끝으로 34~36줄은 데이터 소비자 프로그램의 주 처리 반복문에 쓸 첫 값 경로 이름을 준비합니다. 값 경로 이름은 이렇게 만듭니다. 그다음 내부 함수 lststats의 주 처리 반복문을 부릅니다. 이 함수가 돌아오면 RSiClosex를 부르고 프로그램을 끝냅니다.
영어 원문
Initializing and terminating the program
The main function of the sample program uses the three subroutines as shown in the following code segment. The lines 12 through 15 use any command line argument to override the default host name obtained by the uname function. Then lines 17 through 28 initialize the RSI interface using the RSiInitx and RSiOpenx subroutines. The program exits if the initialization fails.
(41줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
Finally, lines 34 through 36 prepare an initial value path name for the main processing loop of the data-consumer program. This is the method followed to create the value path names. Then, the main processing loop in the internal lststats function is called. If this function returns, issue an RSiClosex call and exit the program.
statset 정의하기
결국 예제 데이터 소비자 프로그램이 xmtopas 데몬에서 데이터 공급을 받게 하려는 것입니다. 그러려면 관심 있는 통계 묶음을 정의하는 SpmiStatSet부터 준비합니다. RSiCreateStatSetx 서브루틴으로 합니다.
[01] voidlststats(char *basepath)
[02] {
[03] struct SpmiStatSet *ssp;
[04] char tmp[128];
[05]
[06] if (!(ssp = RSiCreateStatSetx(rsh)))
[07] {
[08] fprintf(stderr, “RsiCons1 can\’t create StatSet\n”);
[09] exit(62);
[10] }
[11]
[12] strcpy(tmp, basepath);
[13] strcat(tmp, “CPU/cpu0”);
[14] if ((tix = addstat(tix, ssp, tmp, “cpu0”)) == -1)
[15] {
[16] if (strlen(RSiEMsg))
[17] fprintf(stderr, “%s”, RSiEMsg);
[18] exit(63);
[19] }
[20]
[21] RSiStartFeedx(rsh, ssp, 1000);
[22] while(TRUE)
[23] RSiMainLoopx(499);
[24] }
예제 프로그램에서는 위 6~10줄처럼 로컬 함수 lststats 안에서 SpmiStatSet을 만듭니다.
12~19줄은 로컬 함수 addstat("statset에 통계 더하기")를 부릅니다. addstat는 문맥 계층에서 CPU 관련 통계를 모두 찾아, 정보를 모으고 출력할 배열을 초기화합니다. 앞 두 줄은 함수에 넘긴 값 경로 이름 뒤에 CPU/cpu0을 붙입니다. 그 결과 문자열이 cpu0의 CPU 관련 통계가 모두 든 문맥의 경로 이름입니다. 경로 이름은 끝에 슬래시가 없는 hosts/hostname/CPU/cpu0 형식이며, 값 경로 이름을 인수로 받는 서브루틴이 기대하는 형식입니다. addstat 함수는 다음 절에 나오며, 순회 함수 세 개로 CPU 관련 통계에 접근합니다.
데이터 소비자의 데이터 공급 초기화:
main 부분의 주 처리 함수에서 아직 설명하지 않은 것은 21~23줄뿐입니다. 첫 줄은 RSiStartFeedx 서브루틴을 불러 xmtopas 데몬에 SpmiStatSet의 통계 관찰값을 보내기 시작하라고 알립니다. 다음 두 줄은 무한 반복문으로 RSiMainLoopx 함수를 불러 들어오는 data_feed 패킷을 확인합니다.
xmtopas 데몬의 데이터 공급 흐름을 제어하는 서브루틴이 두 개 더 있지만 예제 프로그램에서는 쓰지 않습니다. RSiChangeFeedx와 RSiStopFeedx 설명을 봅니다.
영어 원문
Defining a Statset
Eventually, you want the sample of the data-consumer program to receive data feeds from the xmtopas daemon. Thus, start preparing the SpmiStatSet, which defines the set of statistics with which you are interested. This is done with the RSiCreateStatSetx subroutine.
(24줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
In the sample program, the SpmiStatSet is created in the local lststats function shown previously in lines 6 through 10.
Lines 12 through 19 invoke the local function addstat (Adding Statistics to the Statset), which finds all the CPU-related statistics in the context hierarchy and initializes the arrays to collect and print the information. The first two lines expand the value path name passed to the function by appending CPU/cpu0. The resulting string is the path name of the context where all CPU-related statistics for cpu0 are held. The path name has the hosts/hostname/CPU/cpu0 format without a terminating slash, which is what is expected by the subroutines that take a value path name as an argument. The addstat function is shown in the next section. It uses three of the traversal functions to access the CPU-related statistics.
Data-Consumer initialization of data feeds
The only part of the main processing function in the main section yet to explain consists of lines 21 through 23. The first line simply tells the xmtopas daemon to start feeding observations of statistics for an SpmiStatSet by issuing the RSiStartFeedx subroutine call. The next two lines define an infinite loop that calls the RSiMainLoopx function to check for incoming data_feed packets.
There are two more subroutines concerned with controlling the flow of data feeds from xmtopas daemon. Neither is used in the sample program. The subroutines are described in RSiChangeFeedx and RSiStopFeedx structures.
statset에 통계 더하기
[01] int addstat(int ix, struct SpmiStatSet *ssp, char *path, char *txt)
[02] {
[03] cx_handle *cxh;
[04] int i = ix;
[05] char tmp[128];
[06] struct SpmiStatLink *statlink;
[07]
[08] if (!(cxh = RSiPathGetCxx(rsh, path)))
[09] {
[10] fprintf(stderr, “RSiPathGetCxx can\’t access host %s (path %s)\n”, host, path);
[11] exit(61);
[12] }
[13]
[14] if ((statlink = RSiFirstStatx(rsh, cxh, navn, desc)))
[15] {
[16] while (statlink)
[17] {
[18] if (i > 23)
[19] break;
[20] strcpy(head1[i], txt);
[21] strcpy(head2[i], *navn);
[22] strcpy(tmp, path);
[23] strcat(tmp, “/”);
[24] strcat(tmp, *navn);
[25] if (!(svp[i] = RSiPathAddSetStatx(rsh, ssp, tmp)))
[26] return(-1);
[27] i++;
[28] statlink = RSiNextStatx(rsh, cxh, statlink, navn, desc);
[29] }
[30] }
[31] return(i);
[32] }
예제 프로그램은 812줄에서 RSiPathGetCxx를 씁니다. 이어서 1430줄에서 두 서브루틴 RSiFirstStatx와 RSiNextStatx로 CPU 문맥에 정의된 통계 값을 모두 가져옵니다.
2021줄은 문맥의 짧은 이름("cpu0")과 통계의 짧은 이름을 열 머리 출력에 쓰려고 두 배열에 저장합니다. 2224줄은 문맥 전체 경로 이름과 값의 짧은 이름을 이어 통계 값의 전체 경로 이름을 만듭니다. RSiPathAddSetStatx로 SpmiStatSet에 값을 더하려면 이것이 필요하며, 25~26줄에서 더합니다.
영어 원문
Adding Statistics to the Statset
(32줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
The use of RSiPathGetCxx by the sample program is shown in lines 8 through 12. Following that, in lines 14 through 30, two subroutines are used to get all the statistics values defined for the CPU context. This is done by using RSiFirstStatx and RSiNextStatx subroutines.
In lines 20-21, the short name of the context (“cpu0”) and the short name of the statistic are saved in two arrays for use when printing the column headings. Lines 22-24 construct the full path name of the statistics value by concatenating the full context path name and the short name of the value. This is necessary to proceed with adding the value to the SpmiStatSet with the RSiPathAddSetStatx. The value is added by using the lines 25 and 26.
데이터 소비자의 데이터 공급 해석
RSI 인터페이스가 data_feed를 감지할 때마다 RSiOpenx 서브루틴에서 정의한 데이터 공급 콜백 함수가 불리며, RSI 핸들을 인수로 넘깁니다. 예제 프로그램의 데이터 공급 콜백 함수는 다음과 같습니다. 대부분의 줄(9~19줄과 26줄)은 상세 줄 20줄마다 머리를 출력하는 일을 합니다.
[01] void feeding(RSiHandlex rsh, pack *p)
[02] {
[03] int i;
[04] float f;
[05] long v;
[06]
[07] if (p->type != data_feed)
[08] return;
[09] if (lct > 20)
[10] {
[11] printf(“\n\n”);
[12] for (i = 0; i < tix; i++)
[13] printf(“%08s”, head1[i]);
[14] printf(“\n”);
[15] for (i = 0; i < tix; i++)
[16] printf(“%08s”, head2[i]);
[17] printf(“\n”);
[18] lct = 0;
[19] }
[20] for (i = 0; i < tix; i++)
[21] {
[22] v = RSiGetValuex(rsh, svp[i]) * 10.0;
[23] printf(“%6d.%d”, v/10, v%10);
[24] }
[25] printf(“\n”);
[26] lct++;
[27] }
받은 통계 값의 실제 처리는 20~24줄에서 라이브러리 서브루틴 RSiGetValuex로 합니다. 다음은 예제 프로그램 RsiCons1의 출력 예입니다.
$ RsiCons1 umbra
cpu0 cpu0 cpu0 cpu0 cpu0 cpu0 cpu0 cpu0
user kern wait idle uticks kticks wticks iticks
0.0 0.0 0.0 100.0 0.0 0.0 0.0 100.0
0.0 0.0 0.0 100.0 0.0 0.0 0.0 99.9
0.2 3.1 0.0 96.5 0.2 3.2 0.0 96.6
3.5 5.5 1.5 89.1 3.5 5.5 1.5 89.1
5.8 3.4 0.0 90.8 5.8 3.4 0.0 90.8
8.8 8.3 0.1 82.5 8.8 8.3 0.2 82.5
67.5 2.4 3.0 27.0 67.5 2.3 2.9 26.9
16.0 0.6 0.8 82.5 16.0 0.6 0.8 82.6
67.5 5.0 0.0 27.3 67.5 5.0 0.0 27.3
19.0 6.1 0.9 73.8 19.1 6.1 0.9 73.8
22.5 0.8 1.6 75.0 22.5 0.8 1.6 74.9
60.2 6.1 0.0 33.5 60.2 6.1 0.0 33.5
$
영어 원문
Data-Consumer decoding of data feeds
Whenever a data_feed is detected by the RSI interface, the data feed callback function defined in the RSiOpenx subroutine is invoked, passing the RSI handle as an argument to the callback function. The sample program's callback function for data feeds is shown in the following example. Most of the lines in the function are concerned with printing headings after each 20 detail lines printed. This is in line numbers 9 through 19 and 26.
(27줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
Actual processing of received statistics values is done by the lines 20-24. It involves the use of the library RSiGetValuex subroutine. The following is an example of output from the sample program RsiCons1:
(16줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
데이터 공급을 해석하는 다른 방법
data_feed 패킷으로 받은 데이터에 대해 RSiGetValuex 서브루틴으로 얻을 수 있는 것보다 더 알고 싶으면 라이브러리 서브루틴 RSiGetRawValuex를 씁니다.
영어 원문
An Alternative way to decode data feeds
To know more about the data received in data_feed packets than what can be obtained by using the RSiGetValuex subroutine, you can use the library RSiGetRawValuexsubroutine.
데이터 소비자 프로그램 확장하기
앞 절의 예제 프로그램보다 조금 더 할 줄 아는 버전이 /usr/samples/perfmgr/RsiCons.c 파일에 있습니다. 이 프로그램은 데몬이 실행되는 시스템에서 찾은 모든 디스크의 짧은 이름 xfer 통계도 나열합니다. 그러려고 문맥을 순회하는 서브루틴을 더 씁니다.
영어 원문
Expanding the data-consumer program
A slightly more capable version of the sample program discussed in the previous sections is provided as the /usr/samples/perfmgr/RsiCons.c file. This program also lists the statistics with the short name xfer for all the disks found in the system where the daemon runs. To do so, the program uses some additional subroutines to traverse contexts.
문맥 순회하기
다음 adddisk 함수는 RSiFirstCxx, RSiNextCxx, RSiInstantiatex 서브루틴을 RSiPathGetCxx와 함께 써서 모든 하위 문맥에 빠짐없이 접근하는 방법을 보여 줍니다. 예제 프로그램의 내부 함수 addstat로 각 하위 문맥의 통계를 SpmiStatSet 구조체에 더합니다. 시작 문맥 아래 모든 수준의 하위 문맥을 돌고 싶으면 재귀 함수로 쉽게 만들 수 있습니다.
01] int adddisk(int ix, struct SpmiStatSet *ssp, char *path)
[02] {
[03] int i = ix;
[04] char tmp[128];
[05] cx_handle *cxh;
[06] struct SpmiStatLink *statlink;
[07] struct SpmiCxLink *cxlink;
[08]
[09] cxh = RSiPathGetCxx(rsh, path);
[10] if ((!cxh) || (!cxh->cxt))
[11] {
[12] if (strlen(RSiEMsg))
[13] fprintf(stderr, “%s”, RSiEMsg);
[14] fprintf(stderr, “RSiPathGetCxx can\’t access host %s (path %s)\n”,
[15] host, path);
[16] exit(64);
[17] }
[18] if (rsh->pi->data.getcx.context.inst_freq == SiContInst)
[19] {
[20] if ((i = RSiInstantiatex(rsh, cxh)))
[21] return(-1);
[22] }
[23] if ((cxlink = RSiFirstCxx(rsh, cxh, navn, desc)))
[24] {
[25] while (cxlink)
[26] {
[27] strcpy(tmp, path);
[28] if (strlen(tmp))
[29] strcat(tmp, “/”);
[30] if (*navn)
[31] strcat(tmp, *navn);
[32] if ((i = addstat(i, ssp, tmp, *navn)) == -1)
[33] {
[34] if (strlen(RSiEMsg))
[35] fprintf(stderr, “%s”, RSiEMsg);
[36] exit(63);
[37] }
[38] cxlink = RSiNextCxx(rsh, cxh, cxlink, navn, desc);
[39] }
[40] }
[41] return(i);
[42] }
AIX 운영 체제 호스트의 xmtopas 데몬에 대해 RsiCons 프로그램을 실행한 출력은 다음과 같습니다.
$ RsiCons encee
CPU CPU CPU CPU hdisk3 hdisk1 hdisk0 cd0
uticks kticks wticks iticks xfer xfer xfer xfer
19.6 10.0 4.1 67.1 2.7 4.1 0.0 0.0
10.9 15.3 8.2 65.3 0.0 8.2 0.0 0.0
0.5 2.0 0.0 97.5 0.0 0.0 0.0 0.0
10.5 4.0 0.0 85.5 0.0 0.0 0.0 0.0
55.4 8.9 0.0 35.4 2.4 0.0 0.0 0.0
19.0 5.5 0.0 75.5 0.0 0.0 0.0 0.0
5.9 6.4 0.0 87.4 0.0 0.0 0.0 0.0
10.5 7.0 0.0 82.5 0.0 0.0 0.0 0.0
7.9 7.4 0.0 84.4 0.0 0.0 0.0 0.0
88.5 8.5 3.0 0.0 9.5 4.5 0.0 0.0
89.4 8.9 1.4 0.0 5.9 0.0 0.0 0.0
92.5 5.5 2.0 0.0 9.0 8.5 0.0 0.0
71.0 6.0 23.0 0.0 44.0 41.0 0.0 0.0
37.9 2.4 58.9 0.4 67.9 61.4 0.0 0.0
17.5 4.5 0.0 78.0 1.5 3.0 0.0 0.0
0.5 1.5 10.0 88.0 7.5 1.5 0.0 0.0
$
영어 원문
Traversing contexts
The adddisk function in the following list shows how the RSiFirstCxx, RSiNextCxx, and the RSiInstantiatex subroutines are combined with RSiPathGetCxx to make sure all subcontexts are accessed. The sample program's addstat internal function is used to add the statistics of each subcontext to the SpmiStatSet structure. A programmer who wanted to traverse all levels of subcontexts below a start context could easily create a recursive function to do this.
(42줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
The output from the RsiCons program when run on the xmtopas daemon on an AIX operating system host is shown in the following example.
(20줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
데이터 공급자 초대하기
RSiInvitex 서브루틴을 쓰면 사용자가 감시할 호스트를 직접 지정하게 하는 대신, 데이터 공급자가 될 수 있는 호스트 목록을 보여 주는 프로그램을 만들 수 있습니다.
영어 원문
Inviting data suppliers
The RSiInvitex subroutine allows to design programs that can present the end user with a list of potential data-supplier hosts rather than requiring the user to specify which host to monitor.
데이터 공급자 찾기
RSiInvitex 서브루틴은 다음 방법 가운데 하나 이상으로 초대 메시지 are_you_there를 보낼 IP 주소를 얻습니다.
뒤의 두 방법은 $HOME/Rsi.hosts 파일이 있어야 합니다. PTX에는 Rsi.hosts 파일의 다른 위치도 있습니다. 데이터 공급자 호스트를 초대하는 세 방법은 다음과 같습니다.
- 사용자가 막지 않으면, 로컬 호스트의 각 네트워크 인터페이스에 해당하는 방송(broadcast) 주소를 찾아 인터페이스마다 그 방송 주소로 초대 메시지를 보냅니다. Localhost(루프백) 인터페이스나 X.25, SLIP 같은 점대점(point-to-point) 인터페이스에는 방송하지 않습니다.
$HOME/Rsi.hosts파일에 인터넷 방송 주소 목록이 있으면 그 방송 주소마다 초대 메시지를 보냅니다. 로컬 인터페이스의 방송 주소를 적으면 그 인터페이스에는 방송이 두 번 갑니다. 초대가 사라질 가능성을 줄이려고 이를 일부러 쓸 수도 있습니다.$HOME/Rsi.hosts파일에 호스트 이름 목록이 있으면 목록의 호스트마다 IP 주소를 찾아 메시지를 보냅니다. 찾기는gethostbyname()호출로 하므로, 데이터 소비자 응용 프로그램이 실행되는 호스트에서 쓰는 이름 서비스로 주소를 찾습니다.
$HOME/Rsi.hosts 파일의 형식은 간단합니다. 키워드는 하나만 알아보며 줄의 첫 칸에 있을 때만 알아봅니다. 그 키워드는 nobroadcast이며, are_you_there 메시지를 위의 1번 방법으로 방송하지 말라는 뜻입니다. 네트워크에 호스트가 많은데 그 가운데 정해진 일부만 원격 감시하려 할 때 유용합니다. 방송은 하지 않고 세 호스트에 직접 연락하려면 $HOME/Rsi.hosts 파일을 다음처럼 씁니다.
nobroadcast
birte.austin.ibm.com
gatea.almaden.ibm.com
umbra
이 예에서 보듯 감시할 호스트가 꼭 같은 도메인이나 로컬 네트워크에 있을 필요는 없습니다. 다만 느린 통신 회선을 거친 원격 감시는 그 회선의 다른 사용자에게도 자신에게도 환영받기 어렵습니다.
데이터 소비자 호스트와 같은 서브넷에 있지 않은 원격 호스트를 감시하려면 $HOME/Rsi.hosts 파일에 다른 서브넷의 방송 주소나 그 호스트들의 이름을 모두 적어야 합니다. IP 방송은 IP 라우터나 게이트웨이를 넘어가지 않기 때문입니다.
다음 예는 모든 로컬 인터페이스로 방송하고, 방송 주소 129.49.143.255로 식별되는 서브넷에도 방송하고, umbra라는 호스트도 초대하려는 경우입니다(이 방송 주소에 해당하는 서브넷 마스크는 255.255.240.0이고 방송 범위는 129.49.128.0~129.49.143.255입니다). 원문 예에는 129.49.143.255 한 줄만 보이지만 umbra 줄도 들어가야 합니다.
129.49.143.255
RSiInvitex 서브루틴은 이름 서버가 동작하지 않거나 응답이 비정상적으로 느리면 호스트 이름 대신 IP 주소를 돌려줍니다. 호스트 목록을 일부 만든 뒤 이름 서버가 실패하면 같은 호스트가 IP 주소로 한 번, 호스트 이름으로 한 번, 두 번 나올 수 있습니다.
RSiInvitex 서브루틴의 실행 시간은 주로 $HOME/Rsi.hosts 파일에 적은 방송 주소 수에 달려 있습니다. 방송 주소 하나마다 대략 50밀리초와 응답 처리 시간이 늘어납니다. 서브루틴의 최소 실행 시간은 대략 1.5초이며, 그동안 응용 프로그램은 콜백 함수를 지정했고 그 콜백에 넘길 패킷이 도착했을 때만 제어를 받습니다.
영어 원문
Identifying data suppliers
The RSiInvitex subroutine uses one or more of the following methods to obtain the Internet Protocol (IP) addresses to which an invitational are_you_there message can be sent.
The last two methods depend on the presence of the $HOME/Rsi.hosts file. PTX also has alternative locations of the Rsi.hosts file. The three ways to invite data-supplier hosts are:
Unless instructed not to by the user, the broadcast address corresponding to each of the network interfaces of the local host is found. The invitational message is sent on each network interface using the corresponding broadcast address. Broadcasts are not attempted on the Localhost (loopback) interface or on point-to-point interfaces such as X.25 or Serial Line Interface Protocol (SLIP) connections.
If a list of Internet broadcast addresses is supplied in the
$HOME/Rsi.hostsfile, an invitational message is sent on each such broadcast address. Note that if you specify the broadcast address of a local interface, broadcasts are sent twice on those interfaces. You may want to use this as a feature in order to minimize the likelihood of the invitation being lost.If a list of host names is supplied in the
$HOME/Rsi.hostsfile, the host IP address for each host in the list is looked up and a message is sent to each host. The look-up is done through agethostbyname()call, so that whichever name service is active for the host where the data-consumer application runs is used to find the host address.
The $HOME/Rsi.hosts file has a simple layout. Only one keyword is recognized and only if placed in column one of a line. That keyword is:
nobroadcast and means that the are_you_there message should not be broadcast using method 1 shown previously. This option is useful in situations where a large number of hosts are on the network and only a well-defined subset should be remotely monitored. To say that you don't want broadcasts but want direct contact to three hosts, your $HOME/Rsi.hosts file might look like this:
nobroadcast
birte.austin.ibm.com
gatea.almaden.ibm.com
umbra
This example shows that the hosts to monitor do not necessarily have to be in the same domain or on a local network. However, doing remote monitoring across a low-speed communications line is unlikely to be popular; neither with other users of that communications line nor with yourself.
Be aware that whenever you want to monitor remote hosts that are not on the same subnet as the data-consumer host, you must specify the broadcast address of the other subnets or all the host names of those hosts in the $HOME/Rsi.hosts file. The reason is that IP broadcasts do not propagate through IP routers or gateways.
The following example illustrates a situation where you want to do broadcasting on all local interfaces, want to broadcast on the subnet identified by the broadcast address 129.49.143.255, and also want to invite the host called umbra. (The subnet mask corresponding to the broadcast address in this example is 255.255.240.0 and the range of addresses covered by the broadcast is 129.49.128.0 - 129.49.143.255.)
129.49.143.255
If the RSiInvitex subroutine detects that the name server is inoperational or has abnormally long response time, it returns the IP addresses of hosts rather than the host names. If the name server fails after the list of hosts is partly built, the same host may appear twice, once with its IP address and once with its host name.
The execution time of the RSiInvitex subroutine depends primarily on the number of broadcast addresses you place in the $HOME/Rsi.hosts file. Each broadcast address increases the execution time with roughly 50 milliseconds plus the time required to process the responses. The minimum execution time of the subroutine is roughly 1.5 seconds, during which time your application only gets control if callback functions are specified and if packets arrive that must be given to those callback functions.
전체 화면 문자 기반 모니터
이 프로그램은 API와 curses 프로그래밍 인터페이스로 화면 가득 통계를 보여 줍니다.
데이터 소비자 API로 만든 또 다른 예제 프로그램이 chmon입니다. 소스 코드는 /usr/samples/perfmgr/chmon.c 파일에 있으며, Manager 구성 요소를 설치할 때 실행 파일로도 저장됩니다. 화면 예는 다음과 같습니다.
Data-Consumer API Remote Monitor for host Tue Apr 14 09:09:05
1992
CHMON Sample Program *** birte *** Interval: 5 seconds
% CPU EVENTS/QUEUES FILE/TTY
Kernel 13.3 |#### | Pswitch 1295 Readch 24589
User 23.7 |####### | Syscall 6173 Writech 1646
Wait 6.5 |## | Reads 487 Rawin 0
Idle 56.1 |################ | Writes 143 Ttyout 106
Forks 1 Igets 1763
PAGING counts PAGING SPACE REAL MEM 48MB Execs 1 Namei 809
Faults 131 % Used 33.7 % Comp 68.0 Runqueue 1 Dirblk 174
Steals 0 % Free 66.2 % NonComp 15.0 Swapqueue 0 Reads 48
Reclaim 0 Size,MB 96 % Client 4.0 Writes 143
PAGING page/s DISK Read Write % NETWORK Read Write
Pgspin 0 ACTIVITY KB/sec KB/sec Busy ACTIVITY KB/sec KB/sec
Pgspout 0 hdisk0 0.0 35.1 15.7 lo0 1.1 1.1
Pagein 0 hdisk1 0.0 0.0 0.0 tr0 1.1 0.0
Pageout 11 hdisk2 0.0 9.5 3.5
Sios 10 cd1 0.0 0.0 0.0
Process wait (514) %cpu 63.2, PgSp: 0.0mb, uid:
Process xlcentry (12657) %cpu 58.0, PgSp: 1.1mb, uid: birte
Process make (21868) %cpu 15.0, PgSp: 0.2mb, uid: birte
Process make (5998) %cpu 15.0, PgSp: 0.1mb, uid: birte
chmon 명령줄은 다음과 같습니다.
chmon[-iseconds_interval][-pno_of_processes][hostname>]
| 인수 | 설명 |
|---|---|
seconds_interval |
관찰 간격(초). 플래그와 간격 사이에 공백을 넣으면 안 됩니다. 기본 5초 |
no_of_processes |
보여 줄 "hot" 프로세스 수. CPU를 많이 쓸수록 더 "hot"하다고 봅니다. 플래그와 수 사이에 공백을 넣으면 안 됩니다. 기본 0(프로세스 안 보임) |
hostname |
감시할 호스트 이름. 기본은 로컬 호스트입니다. 예제 프로그램은 관찰을 2,000번 하거나 창에서 "q"를 누르면 끝납니다. |
영어 원문
A Full-Screen, character-based monitor
This program uses the API and the curses programming interface to create a screen full of statistics.
Another sample program written to the data-consumer API is the chmon program . Source code to the program is in /usr/samples/perfmgr/chmon.c.file. The chmon program is also stored as an executable during the installation of the Manager component. An example program follows:
(23줄짜리 예는 위 한글 본문에 그대로 실었습니다.)
The chmon command line is:
chmon[-iseconds_interval][-pno_of_processes][hostname>]
seconds_interval— Is the interval between observations. Must be specified in seconds. No blanks must be entered between the flag and the interval. Defaults to 5 seconds.no_of_processes— Is the number of “hot” processes to be shown. A process is considered “hotter” the more CPU it uses. No blanks must be entered between the flag and the count field. Defaults to 0 (no) processes.- hostname — Is the host name of the host to be monitored. Default is the local host. The sample program exits after 2,000 observations have been taken, or when you type the letter “q” in its window.
RSI 오류 코드 목록
모든 RSI 서브루틴은 상수로 오류 코드를 정의합니다.
RSI 오류 코드와 설명은 다음과 같습니다.
| 기호 이름 | 번호 | 설명 |
|---|---|---|
RSiTimeout |
280 | 요청의 응답을 기다리다 시간 초과가 났습니다. |
RSiBusy |
281 | RSiOpenx를 불렀지만 다른 것이 이미 진행 중입니다. |
RSiSendErr |
282 | 라이브러리가 sendto() 시스템 호출로 UDP 패킷을 보내다 오류가 났습니다. |
RSiPollErr |
283 | poll()이나 select() 시스템 호출을 내거나 처리하다 시스템 오류가 났습니다. |
RSiRecvErr |
284 | recvfrom() 시스템 호출로 들어오는 UDP 패킷을 읽다 시스템 오류가 났습니다. |
RSiSizeErr |
285 | recvfrom() 시스템 호출이 길이나 원본 주소가 잘못된 UDP 패킷을 돌려줬습니다. |
RSiResync |
286 | 보낸 요청의 응답을 기다리는 동안 다음 가운데 하나가 일어나 호출 프로그램에 오류를 돌려줬습니다. 1) 예외 패킷을 처리하다 오류가 남. 2) i_am_back 패킷을 처리하다 오류가 남. 3) are_you_there가 아닌 요청의 응답으로 i_am_back 패킷을 받음. 4) 응답을 기다리는 동안 비동기 함수가 원격 호스트의 핸들을 닫음. 성공 코드를 돌려줄 때도 설정될 수 있으며, 그때는 응답을 기다리는 동안 예외 패킷이나 i_am_back 패킷을 성공적으로 처리했다는 뜻입니다. |
RSiBadStat |
287 | 받은 데이터 패킷에 나쁜 상태 코드가 있습니다. |
RSiBadArg |
288 | RSI 서브루틴에 올바르지 않은 인수를 넘겼습니다. |
RSiBadHost |
289 | IP 주소로 올바른 호스트 주소를 만들 수 없거나, 이름 서비스가 호스트 이름을 모릅니다. |
RSiDupHost |
290 | 어떤 호스트에 RSiOpenx를 불렀지만, 같은 IP 주소에 다른 호스트 이름으로 이미 연결이 열려 있습니다. |
RSiSockErr |
291 | 소켓을 열거나 소켓으로 통신하다 오류가 났습니다. |
RSiNoPort |
292 | 원격 공급자를 초대할 때 쓸 포트 번호를 찾을 수 없습니다. /etc/services 파일이나 NIS(Yellow Pages) 서버에 xmquery 항목이 없는 것이 흔한 원인입니다. |
RSiNoMatch |
293 | 다음 가운데 하나입니다. 1) RSiStatGetPathx의 SpmiStatVals 인수가 올바르지 않음. 2) RSiPathAddSetStatx의 SpmiStatSet 인수가 올바르지 않거나 마지막 인수의 경로 이름이 없음. 3) RSiAddSetHotx의 SpmiHotSet 인수가 올바르지 않거나, 조부모 문맥이 없거나, 그 하위 문맥 어디에도 지정한 통계가 없음. 4) RSiDelSetStatx의 SpmiStatSet이나 SpmiStatVals 인수가 올바르지 않음. 5) RSiDelSetHotx의 SpmiHotSet이나 SpmiHotVals 인수가 올바르지 않음. 6) RSiPathGetCxx에 준 경로 이름이 없거나, RSiGetValuex·RSiGetRawValuex의 SpmiStatVals 인수가 올바르지 않음. 7) RSiGetHotItemx의 SpmiHotSet 인수가 올바르지 않음. |
RSiInstErr |
294 | 원격 문맥을 인스턴스화하다 오류가 났습니다. |
RSiNoFeed |
295 | RSiGetValuex로 데이터 값을 꺼낼 때, 원격 데이터 공급자가 그 값을 올바르지 않다고 표시했습니다. |
RSiTooMany |
296 | 현재 버퍼 크기가 허용하는 것보다 많은 값을 statset에 더하려 했습니다. |
RSiNoMem |
297 | 메모리 할당 오류 |
RSiNotInit |
298 | RSiInitx를 부르기 전에 RSI 호출을 했습니다. |
RSiNoLicense |
299 | 라이선스가 만료되었거나 없습니다. |
RSiNotSupported |
300 | 서브루틴 호출에 원격 시스템의 xmtopas 데몬이 지원하는 것보다 나중의 프로토콜 버전이 필요합니다. |
영어 원문
List of RSI Error Codes
All RSI subroutines use constants to define error codes.
The RSI Error Code table lists the error descriptions.
| Symbolic Name | Number | Description |
|---|---|---|
| RSiTimeout | 280 | A time-out occurred while waiting for a response to a request. |
| RSiBusy | 281 | An RSiOpenx subroutine was issued, but another is already active. |
| RSiSendErr | 282 | An error occurred when the library attempted to send a UDP packet with the sendto() system call. |
| RSiPollErr | 283 | A system error occurred while issuing or processing a poll() or select() system call. |
| RSiRecvErr | 284 | A system error occurred while attempting to read an incoming UDP packet with the recvfrom() system call. |
| RSiSizeErr | 285 | A recvfrom() system call returned a UDP packet with incorrect length or incorrect source address. |
| RSiResync | 286 | While waiting for a response to an outgoing request, one of the following occurred and cause an error return to the calling program: 1. An error occurred while processing an exception packet. 2. An error occurred while processing an i_am_back packet. 3. An i_am_back packet was received in response to an output request other than are_you_there. 4. While waiting for a response to an outgoing request, some asynchronous function closed the handle for the remote host. The code may also be set when a success return code is returned to the caller, in which case it shows that either an exception packet or an i_am_back packet was processed successfully while waiting for a response. |
| RSiBadStat | 287 | A bad status code was received in the data packet received. |
| RSiBadArg | 288 | An argument that is not valid was passed to an RSi subroutine. |
| RSiBadHost | 289 | A valid host address cannot be constructed from an IP address or the nameservice doesn't know the hostname. |
| RSiDupHost | 290 | An RSiOpenx call was issued against a host but a connection is already open to a host with this IP address and a different hostname. |
| RSiSockErr | 291 | An error occurred while opening or communicating with a socket. |
| RSiNoPort | 292 | The RSi is unable to find the port number to use when inviting remote suppliers. The likely cause is that the xmquery entry is missing from the /etc/services file or the NIS (Yellow Pages) server. |
| RSiNoMatch | 293 | One of the following occurred: 1. The SpmiStatVals argument on the RSiStatGetPathx call is not valid. 2. On an RSiPathAddSetStatx call, the SpmiStatSet argument is not valid or the path name given in the last argument does not exist. 3. On an RSiAddSetHotx call, the SpmiHotSet argument is not valid, the grand parent context doesn't exist or none of its subcontexts contain the specified statistic. 4. On an RSiDelSetStatx call, the SpmiStatSet or the SpmiStatVals argument is not valid. 5. On an RSiDelSetHotx call, the SpmiHotSet or the SpmiHotVals argument is not valid. 6. On an RSiPathGetCxx call, the path name given does not exist. On an RSiGetValuex or RSiGetRawValuex call, the SpmiStatVals argument is not valid. 7. On an RSiGetHotItemx call, the SpmiHotSet argument was not valid. |
| RSiInstErr | 294 | An error was returned when attempting to instantiate a remote context. |
| RSiNoFeed | 295 | When extracting a data value with the RSiGetValuex call, the data value was marked as not valid by the remote data supplier. |
| RSiTooMany | 296 | An attempt was made to add more values to a statset than the current buffer size permits. |
| RSiNoMem | 297 | Memory allocation error. |
| RSiNotInit | 298 | An RSi call was attempted before an RSiInitx call was issued. |
| RSiNoLicense | 299 | License expired or no license found. |
| RSiNotSupported | 300 | The subroutine call requires a later protocol version that is the one supported by the remote system's xmtopas daemon. |
자주 쓰는 형태
lslpp -l perfagent.server # xmtopas가 든 성능 에이전트
ls /usr/samples/perfmgr # RsiCons1.c, RsiCons.c, chmon.c
chmon -i10 -p5 otherhost # 10초 간격, hot 프로세스 5개
# $HOME/Rsi.hosts 예
nobroadcast
hostA.example.com
hostB.example.com
portrange 3001 3003