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