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

NAME

6       pmParseMetricSpec,  pmFreeMetricSpec  -  uniform  metric  specification
7       parser
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11
12       int pmParseMetricSpec(const char *string, int isarch, char *source,
13               pmMetricSpec **rsltp, char **errmsg);
14       void pmFreeMetricSpec(pmMetricSpec *rslt);
15
16       cc ... -lpcp
17

DESCRIPTION

19       pmParseMetricSpec accepts a string specifying the name of a PCP perfor‐
20       mance metric, and optionally the source (either a hostname or a PCP ar‐
21       chive  log  filename) and instances for that metric.  The syntax is de‐
22       scribed in PCPIntro(1).
23
24       If neither host nor archive component of the  metric  specification  is
25       provided,  the  isarch and source arguments are used to fill in the re‐
26       turned pmMetricSpec structure.
27
28       The pmMetricSpec structure that is returned via  rsltp  represents  the
29       parsed string and has the following declaration:
30
31           typedef struct {
32               int     isarch;      /* source type: 0 -> live host, 1 -> archive, 2 -> local context */
33               char    *source;     /* name of source host or archive */
34               char    *metric;     /* name of metric */
35               int     ninst;       /* number of instances, 0 -> all */
36               char    *inst[1];    /* array of instance names */
37           } pmMetricSpec;
38
39       pmParseMetricSpec  returns  0  if  the  given  string  was successfully
40       parsed.  In this case all the storage  allocated  by  pmParseMetricSpec
41       can  be released by a single call to free(3) using the address returned
42       from pmMetricSpec via rsltp.  The convenience macro pmFreeMetricSpec is
43       a thinly disguised wrapper for free(3).
44
45       pmParseMetricSpec  returns  PM_ERR_GENERIC  and a dynamically allocated
46       error message string in errmsg, if the given string does not parse.  Be
47       sure to free(3) the error message string in this situation.
48
49       In  the  case of an error, rsltp is undefined.  In the case of success,
50       errmsg is undefined.  If rsltp->ninst is 0, then rsltp->inst[0] is  un‐
51       defined.
52

SEE ALSO

54       PMAPI(3) and pmLookupName(3).
55
56
57
58Performance Co-Pilot                  PCP                 PMPARSEMETRICSPEC(3)
Impressum