Defining a Statset
SpmiStatSet
, which defines
the set of statistics with which you are interested. This is done
with the RSiCreateStatSetx subroutine.[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] }
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.