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

NAME

6       pmLookupDesc,  pmLookupDescs - obtain descriptions for performance met‐
7       rics
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11
12       int pmLookupDesc(pmID pmid, pmDesc *desc);
13       int pmLookupDescs(int numpmid, pmID *pmids, pmDesc *descs);
14
15       cc ... -lpcp
16

DESCRIPTION

18       Given a Performance Metrics Identifier (PMID) as pmid, the pmLookupDesc
19       routine  fills in the given pmDesc structure, pointed to by the parame‐
20       ter desc, from the current Performance Metrics Application  Programming
21       Interface (PMAPI) context.
22
23       The pmLookupDescs variant provides equivalent functionality for numpmid
24       metrics at once, with the pmids array providing the metric  identifiers
25       to lookup.  It is more efficient as the number of metrics increases, as
26       it avoids round trip latency from multiple individual  requests.   Note
27       that  the error protocol guarantees there is a 1:1 relationship between
28       the elements of desclist and pmidlist, hence both lists contain exactly
29       numpmid elements.  For this reason, the caller is expected to have pre-
30       allocated a suitably sized array for desclist.
31
32       The pmDesc structure provides all of the information  required  to  de‐
33       scribe  and  manipulate a performance metric via the PMAPI, and has the
34       following declaration.
35
36            /* Performance Metric Descriptor */
37            typedef struct {
38                pmID    pmid;   /* unique identifier */
39                int     type;   /* base data type (see below) */
40                pmInDom indom;  /* instance domain */
41                int     sem;    /* semantics of value (see below) *
42                pmUnits units;  /* dimension and units (see below) */
43            } pmDesc;
44
45            /* pmDesc.type -- data type of metric values */
46            #define PM_TYPE_NOSUPPORT        -1    /* not impl. in this version */
47            #define PM_TYPE_32               0    /* 32-bit signed integer */
48            #define PM_TYPE_U32              1    /* 32-bit unsigned integer */
49            #define PM_TYPE_64               2    /* 64-bit signed integer */
50            #define PM_TYPE_U64              3    /* 64-bit unsigned integer */
51            #define PM_TYPE_FLOAT            4    /* 32-bit floating point */
52            #define PM_TYPE_DOUBLE           5    /* 64-bit floating point */
53            #define PM_TYPE_STRING           6    /* array of char */
54            #define PM_TYPE_AGGREGATE        7    /* arbitrary binary data */
55            #define PM_TYPE_AGGREGATE_STATIC 8    /* static pointer to aggregate */
56            #define PM_TYPE_EVENT            9    /* packed pmEventArray */
57            #define PM_TYPE_UNKNOWN          255  /* used in pmValueBlock, not pmDesc */
58
59
60            /* pmDesc.sem -- semantics/interpretation of metric values */
61            #define PM_SEM_COUNTER  1  /* cumulative ctr (monotonic incr) */
62            #define PM_SEM_INSTANT  3  /* instant. value continuous domain */
63            #define PM_SEM_DISCRETE 4  /* instant. value discrete domain */
64
65       The type field in the pmDesc describes various encodings  (or  formats)
66       for a metric's value.
67
68       If  a value is counted in the underlying base instrumentation with less
69       than 32 bits of integer precision, it is the responsibility of the Per‐
70       formance  Metrics  Domain Agent (PMDA) to promote the value to a 32-bit
71       integer before it is exported into the Performance  Metrics  Collection
72       Subsystem  (PMCS); i.e. applications above the PMAPI never have to deal
73       with 8-bit and 16-bit counters.
74
75       If the value of a performance  metric  is  of  type  PM_TYPE_AGGREGATE,
76       PM_TYPE_AGGREGATE_STATIC,  PM_TYPE_EVENT  or PM_TYPE_STRING, the inter‐
77       pretation of the value is unknown to the PMCS.  In these cases, the ap‐
78       plication  using  the value, and the PMDA providing the value must have
79       some common understanding about how the value is structured and  inter‐
80       preted.
81
82       Each  value  for a performance metric is assumed to be drawn from a set
83       of values that can be described in terms of  their  dimensionality  and
84       scale  by a compact encoding as follows.  The dimensionality is defined
85       by a power, or index, in each of 3 orthogonal dimensions, namely Space,
86       Time  and  Count (or Events, which are dimensionless).  For example I/O
87       throughput might be represented as
88                    -1
89          Space.Time
90       while the running total of system calls is Count, memory allocation  is
91       Space and average service time is
92                    -1
93          Time.Count
94       In each dimension there are a number of common scale values that may be
95       used to better encode ranges that might otherwise exhaust the precision
96       of  a  32-bit value.  This information is encoded in the pmUnits struc‐
97       ture which is embedded in the pmDesc structure.
98
99            /*
100             * Encoding for the units (dimensions Time and Space) and scale
101             * for Performance Metric Values
102             *
103             * For example, a pmUnits struct of
104             *      { 1, -1, 0, PM_SPACE_MBYTE, PM_TIME_SEC, 0 }
105             * represents Mbytes/sec, while
106             *      { 0, 1, -1, 0, PM_TIME_HOUR, 6 }
107             * represents hours/million-events
108             */
109            typedef struct {
110                int dimSpace:4;             /* space dimension */
111                int dimTime:4;              /* time dimension */
112                int dimCount:4;             /* event dimension */
113                unsigned int scaleSpace:4;  /* one of PM_SPACE_* below */
114                unsigned int scaleTime:4;   /* one of PM_TIME_* below */
115                int scaleCount:4;           /* one of PM_COUNT_* below */
116            } pmUnits;                      /* dimensional units and scale of value */
117
118            /* pmUnits.scaleSpace */
119            #define PM_SPACE_BYTE   0       /* bytes */
120            #define PM_SPACE_KBYTE  1       /* Kilobytes (1024) */
121            #define PM_SPACE_MBYTE  2       /* Megabytes (1024^2) */
122            #define PM_SPACE_GBYTE  3       /* Gigabytes (1024^3) */
123            #define PM_SPACE_TBYTE  4       /* Terabytes (1024^4) */
124            /* pmUnits.scaleTime */
125            #define PM_TIME_NSEC    0       /* nanoseconds */
126            #define PM_TIME_USEC    1       /* microseconds */
127            #define PM_TIME_MSEC    2       /* milliseconds */
128            #define PM_TIME_SEC     3       /* seconds */
129            #define PM_TIME_MIN     4       /* minutes */
130            #define PM_TIME_HOUR    5       /* hours */
131            /*
132             * pmUnits.scaleCount (e.g. count events, syscalls, interrupts,
133             * etc.) these are simply powers of 10, and not enumerated here,
134             * e.g. 6 for 10^6, or -3 for 10^-3
135             */
136            #define PM_COUNT_ONE    0       /* 1 */
137
138       Special routines (e.g. pmExtractValue(3), pmConvScale(3)) are  provided
139       to manipulate values in conjunction with the pmUnits structure that de‐
140       fines the dimension and scale of the values for  a  particular  perfor‐
141       mance metric.
142
143       Below the PMAPI, the information required to complete the pmDesc struc‐
144       ture, is fetched from the PMDAs, and in this way the format  and  scale
145       of  performance  metrics may change dynamically, as the PMDAs and their
146       underlying instrumentation evolve with time.  In particular, when  some
147       metrics suddenly become 64-bits long, or change their units from Mbytes
148       to Gbytes, well-written applications using the services provided by the
149       PMAPI will continue to function correctly.
150

DIAGNOSTICS

152       These routines return a negative error code to indicate failure.
153
154       PM_ERR_PMID
155              The requested PMID is not known to the PMCS
156
157       PM_ERR_NOAGENT
158              The  PMDA  responsible for providing the metric is currently not
159              available
160
161       pmLookupDesc returns zero to indicate success.
162
163       The result from pmLookupDescs depends on the  presence  of  any  lookup
164       failures, their severity and the number of metrics being looked up.
165
166       1.  If there are no lookup failures, the return value will be numpmid.
167
168       2.  If a fatal error is encountered, the return value will be less than
169           0.  For example PM_ERR_IPC.
170
171       3.  If numpmid is greater than one and non-fatal error(s)  are  encoun‐
172           tered,  the  return  value is the number of metric descriptors that
173           have successfully been looked up (greater than or equal to zero and
174           less than or equal to numpmid).
175
176       4.  If  numpmid is one and a non-fatal error is encountered, the return
177           value is the error code (less than zero).
178
179       When errors are encountered, any metrics that cannot be looked  up  re‐
180       sult  in  the  corresponding  descriptor element of desclist having its
181       pmid field set to PM_ID_NULL.  The slightly convoluted  error  protocol
182       allows bulk lookups, then probing for more error details in the case of
183       a specific failure.
184

SEE ALSO

186       PMAPI(3), pmAtomStr(3),  pmConvScale(3),  pmExtractValue(3),  pmGetCon‐
187       fig(3), pmTypeStr(3), pmUnitsStr(3), pcp.conf(5) and pcp.env(5).
188
189
190
191Performance Co-Pilot                  PCP                      PMLOOKUPDESC(3)
Impressum