For each defined performance metric, there is associated metadata encoded in a performance metric description (

`pmDesc`

structure) that describes the format and semantics of the performance metric. The `pmDesc`

structure, in Example 3.2, “ `pmDesc`

Structure”, provides all of the information required to interpret and manipulate a performance metric through the PMAPI. It has the following declaration:

**Example 3.2. pmDesc Structure**

/* Performance Metric Descriptor */ typedef struct { pmID pmid; /* unique identifier */ int type; /* base data type (see below) */ pmInDom indom; /* instance domain */ int sem; /* semantics of value (see below) */ pmUnits units; /* dimension and units (see below) */ } pmDesc;

The

`type`

field in the `pmDesc`

structure describes various encodings of a metric's value. Its value will be one of the following constants:
/* pmDesc.type - data type of metric values */ #define PM_TYPE_NOSUPPORT -1 /* not in this version */ #define PM_TYPE_32 0 /* 32-bit signed integer */ #define PM_TYPE_U32 1 /* 32-bit unsigned integer */ #define PM_TYPE_64 2 /* 64-bit signed integer */ #define PM_TYPE_U64 3 /* 64-bit unsigned integer */ #define PM_TYPE_FLOAT 4 /* 32-bit floating point */ #define PM_TYPE_DOUBLE 5 /* 64-bit floating point */ #define PM_TYPE_STRING 6 /* array of char */ #define PM_TYPE_AGGREGATE 7 /* arbitrary binary data */ #define PM_TYPE_AGGREGATE_STATIC 8 /* static pointer to aggregate */ #define PM_TYPE_EVENT 9 /* packed pmEventArray */ #define PM_TYPE_UNKNOWN 255 /* used in pmValueBlock not pmDesc */

Event records are encoded as a packed array of strongly-typed, well-defined records within a

`pmResult`

structure, using a container metric with a value of type `PM_TYPE_EVENT`

.
If the value of a performance metric is of type

`PM_TYPE_STRING`

, `PM_TYPE_AGGREGATE`

, `PM_TYPE_AGGREGATE_STATIC`

, or `PM_TYPE_EVENT`

, the interpretation of that value is unknown to many PCP components. In the case of the aggregate types, the application using the value and the Performance Metrics Domain Agent (PMDA) providing the value must have some common understanding about how the value is structured and interpreted. Strings can be manipulated using the standard C libraries. Event records contain timestamps, event flags and event parameters, and the PMAPI provides support for unpacking an event record - see the `pmUnpackEventRecords(3)`

man page for details. Further discussion on event metrics and event records can be found in Section 3.6, “Performance Event Metrics”.
`PM_TYPE_NOSUPPORT`

indicates that the PCP collection framework knows about the metric, but the corresponding service or application is either not configured or is at a revision level that does not provide support for this performance metric.
The semantics of the performance metric is described by the

`sem`

field of a `pmDesc`

structure and uses the following constants:
/* pmDesc.sem - semantics of metric values */ #define PM_SEM_COUNTER 1 /* cumulative count, monotonic increasing */ #define PM_SEM_INSTANT 3 /* instantaneous value continuous domain */ #define PM_SEM_DISCRETE 4 /* instantaneous value discrete domain */

Each value for a performance metric is assumed to be drawn from a set of values that can be described in terms of their dimensionality and scale by a compact encoding, as follows:

- The dimensionality is defined by a power, or index, in each of three orthogonal dimensions: Space, Time, and Count (dimensionless). For example, I/O throughput is Space
^{1}.Time^{-1}, while the running total of system calls is Count^{1}, memory allocation is Space^{1}, and average service time per event is Time^{1}.Count^{-1}. - In each dimension, a number of common scale values are defined that may be used to better encode ranges that might otherwise exhaust the precision of a 32-bit value. For example, a metric with dimension Space
^{1}.Time^{-1}may have values encoded using the scale megabytes per second.

This information is encoded in the

`pmUnits`

data structure, shown in Example 3.3, “ `pmUnits`

and `pmDesc`

Structures”. It is embedded in the `pmDesc`

structure :
The structures are as follows:

**Example 3.3. pmUnits and pmDesc Structures**

/* * Encoding for the units (dimensions and * scale) for Performance Metric Values * * For example, a pmUnits struct of * { 1, -1, 0, PM_SPACE_MBYTE, PM_TIME_SEC, 0 } * represents Mbytes/sec, while * { 0, 1, -1, 0, PM_TIME_HOUR, 6 } * represents hours/million-events */ typedef struct { int pad:8; int scaleCount:4; /* one of PM_COUNT_* below */ int scaleTime:4; /* one of PM_TIME_* below */ int scaleSpace:4; /* one of PM_SPACE_* below */ int dimCount:4; /* event dimension */ int dimTime:4; /* time dimension */ int dimSpace:4; /* space dimension } pmUnits; /* dimensional units and scale of value */ /* pmUnits.scaleSpace */ #define PM_SPACE_BYTE 0 /* bytes */ #define PM_SPACE_KBYTE 1 /* Kilobytes (1024) */ #define PM_SPACE_MBYTE 2 /* Megabytes (1024^2) */ #define PM_SPACE_GBYTE 3 /* Gigabytes (1024^3) */ #define PM_SPACE_TBYTE 4 /* Terabytes (1024^4) */ /* pmUnits.scaleTime */ #define PM_TIME_NSEC 0 /* nanoseconds */ #define PM_TIME_USEC 1 /* microseconds */ #define PM_TIME_MSEC 2 /* milliseconds */ #define PM_TIME_SEC 3 /* seconds */ #define PM_TIME_MIN 4 /* minutes */ #define PM_TIME_HOUR 5 /* hours */ /* * pmUnits.scaleCount (e.g. count events, syscalls, * interrupts, etc.) -- these are simply powers of 10, * and not enumerated here. * e.g. 6 for 10^6, or -3 for 10^-3 */ #define PM_COUNT_ONE 0 /* 1 */