1PMDAEVENTARRAY(3)          Library Functions Manual          PMDAEVENTARRAY(3)
2
3
4

NAME

6       pmdaEventNewArray, pmdaEventResetArray, pmdaEventReleaseArray,
7       pmdaEventAddRecord, pmdaEventAddMissedRecord, pmdaEventAddParam,
8       pmdaEventGetAddr, pmdaEventNewHighResArray, pmdaEventResetHighResArray,
9       pmdaEventReleaseHighResArray, pmdaEventAddHighResRecord, pmdaEventAd‐
10       dHighResMissedRecord, pmdaEventHighResAddParam, pmdaEventHighResGetAddr
11       - utilities for PMDAs to build packed arrays of event records
12

C SYNOPSIS

14       #include <pcp/pmapi.h>
15       #include <pcp/impl.h>
16       #include <pcp/pmda.h>
17
18       int pmdaEventNewArray(void);
19       int pmdaEventResetArray(int idx);
20       int pmdaEventReleaseArray(int idx);
21       int pmdaEventAddRecord(int idx, struct timeval *tp, int flags);
22       int pmdaEventAddMissedRecord(int idx, struct timeval *tp, int nmissed);
23       int pmdaEventAddParam(int idx, pmID pmid, int type, pmAtomValue *avp);
24       pmEventArray *pmdaEventGetAddr(int idx);
25
26       int pmdaEventNewHighResArray(void);
27       int pmdaEventResetHighResArray(int idx);
28       int pmdaEventReleaseHighResArray(int idx);
29       int pmdaEventAddHighResRecord(int idx, struct timespec *ts, int flags);
30       int pmdaEventAddHighResMissedRecord(int idx, struct timespec *ts,
31               int nmissed);
32       int pmdaEventHighResAddParam(int idx, pmID pmid, int type,
33               pmAtomValue *avp);
34       pmHighResEventArray *pmdaEventHighResGetAddr(int idx);
35
36       cc ... -lpcp
37

DESCRIPTION

39       A Performance Metrics Domain Agent (PMDA) that wishes to  export  event
40       records (or trace records) is encouraged to use a metric of either type
41       PM_TYPE_EVENT or PM_TYPE_HIGHRES_EVENT  to  encode  a  group  of  event
42       records into a single packed array.
43
44       The  only  difference between the two metric types is the resolution of
45       the timestamp associated with each - in  high  resolution  form  it  is
46       nanosecond  scale  (see clock_gettime(2)), otherwise it is microseconds
47       (see gettimeofday(2)).  For simplicity, we will only refer to the lower
48       resolution API and data structures hereafter - however, the higher res‐
49       olution variants are all named similarly and are used in the same way.
50
51       The packed array of event records format is  defined  in  <pcp/pmapi.h>
52       and  consists  of a pmEventArray structure containing a variable number
53       of pmEventRecord structures, each of which contains a  variable  number
54       of  pmEventParameter  structures,  which in turn may contain a variable
55       length value for each parameter of each event record.
56
57       The higher resolution equivalents are defined in the same location, and
58       the  structures  are  named  the  same.  Note that the pmEventParameter
59       structure has no timestamp associated with it, hence it this  does  not
60       have a high resolution counterpart.
61
62       The  routines  described here are designed to assist the PMDA developer
63       in building a packed array of event records, and managing  all  of  the
64       memory  allocations required to hold each instance of an array of event
65       records in a contiguous buffer.  Normal use would be as part of  PMDA's
66       pmdaFetchCallBack method.
67
68       pmdaEventNewArray is used to create a new event array.  The return val‐
69       ue is a small integer that is used as the idx parameter  to  the  other
70       routines  to  identify  a  specific event array.  If needed, a PMDA can
71       create and use multiple event arrays.
72
73       To start a new cycle and refill an event array from the beginning, call
74       pmdaEventResetArray.
75
76       If the PMDA has finished with an event array, pmdaEventReleaseArray may
77       be used to release the underlying storage and ``close'' the event array
78       so that subsequent attempts to use idx will return PM_ERR_NOCONTEXT.
79
80       To start a new event record, use pmdaEventAddRecord.  The timestamp for
81       the event record is given via tp and the flags parameter may be used to
82       set  the  control  field that determines the type of the event record -
83       flags may be the bit-wise ``or'' of one or more of the  PM_EVENT_FLAG_*
84       values  defined  in  <pcp/pmapi.h>  (but note that PM_EVENT_FLAG_MISSED
85       should not be used in this context).
86
87       If event records have been missed, either because the PMDA cannot  keep
88       up  or because the PMAPI client cannot keep up, then pmdaEventAddMisse‐
89       dRecord may be used.  idx and tp have the same meaning as for pmdaEven‐
90       tAddRecord  and  nmissed  is the number of event records that have been
91       missed at this point in the time-series of event records.  pmdaEventAd‐
92       dMissedRecord  may be called multiple times for a single batch of event
93       records if there are more than one ``missed event record'' episode.
94
95       Once an event record has been started  by  calling  pmdaEventAddRecord,
96       one or more event parameters may be added using pmdaEventAddParam.  The
97       pmid and type parameters decribe the PMID of the parameter and the data
98       type (one of the PM_TYPE_* values from <pcp/pmapi.h>) of the value that
99       is passed via avp.  type should one where the size of the value is  im‐
100       plied   by   the  type  or  by  the  length  of  a  string  value  (for
101       PM_TYPE_STRING) or encoded within avp->vbp (for PM_TYPE_AGGREGATE).
102
103       Once the packed array has been constructed, pmdaEventGetAddr should  be
104       used  to  initialize  the ea_type and ea_len fields at the start of the
105       pmEventArray and return the base address of the event array that is as‐
106       signed to the vp field of the pmAtomValue structure that the pmdaFetch‐
107       CallBack method should return.
108

EXAMPLE

110       The following skeletal code shows how these routines might be used.
111
112       int             sts;
113       int             myarray;
114       int             first = 1;
115       pmEventArray    eap;
116
117       if (first) {
118          first = 0;
119          if ((myarray = pmdaEventNewArray()) < 0) {
120             // report error and fail
121          }
122       }
123
124       pmdaEventResetArray(myarray);
125
126       // loop over all event records to be exported
127       ... {
128          struct timeval   stamp;
129          int              flags;
130
131          // establish timestamp and set flags to 0 or some combination
132          // of PM_EVENT_FLAG_POINT, PM_EVENT_FLAG_START, PM_EVENT_FLAG_ID,
133          // etc
134          if ((sts = pmdaEventAddRecord(myarray, &stamp, flags)) < 0) {
135             // report error and fail
136          }
137
138          // loop over all parameters for this event record
139          ... {
140             pmID          pmid;
141             int           type;
142             pmAtomValue   atom;
143
144             // construct pmid, type and atom for the parameter and
145             // its value
146             if ((sts = pmdaEventAddParam(myarray, pmid, type, &atom)) < 0) {
147             // report error and fail
148             }
149          }
150
151          // if some event records were missed (could be at the start
152          // of the exported set, or at the end, or in the middle, or
153          // a combination of multiple missed record episodes)
154          ... {
155             int              nmiss;
156             struct timeval   stamp;
157
158             if ((sts = pmdaEventAddMissedRecord(myarray, &stamp, nmiss)) < 0) {
159             // report error and fail
160             }
161          }
162       }
163
164       // finish up
165       eap = pmdaEventGetAddr(myarray);
166

SEE ALSO

168       clock_gettime(2), gettimeofday(2), pmdaEventNewQueue(3),  pmdaEventNew‐
169       Client(3), PMDA(3) and pmEventFlagsStr(3).
170
171
172
173Performance Co-Pilot                  PCP                    PMDAEVENTARRAY(3)
Impressum