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

NAME

6       pmLookupDesc, pmReceiveDesc, pmRequestDesc - obtain a description for a
7       performance metric
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11
12       int pmLookupDesc(pmID pmid, pmDesc *desc)
13       int pmRequestDesc(int ctx, pmID pmid)
14       int pmReceiveDesc(int ctx, pmDesc *desc)
15
16       cc ... -lpcp
17

DESCRIPTION

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

SEE ALSO

151       PMAPI(3), pmAtomStr(3),  pmConvScale(3),  pmExtractValue(3),  pmGetCon‐
152       fig(3), pmTypesStr(3), pmUnitsStr(3), pcp.conf(4) and pcp.env(4).
153

DIAGNOSTICS

155       PM_ERR_PMID
156              The requested PMID is not known to the PMCS
157
158       PM_ERR_NOAGENT
159              The  PMDA  responsible for providing the metric is currently not
160              available
161
162       PM_ERR_CTXBUSY
163              Context is currently in use by another asynchronous call.
164
165
166
167Performance Co-Pilot                  SGI                      PMLOOKUPDESC(3)
Impressum