summaryrefslogtreecommitdiff
path: root/man/man3/pmparsemetricspec.3
blob: bec37fb754f94efca9b7868d0668b917544a91d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'\"macro stdmacro
.\"
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\" 
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\" 
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\" 
.\"
.TH PMPARSEMETRICSPEC 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmParseMetricSpec\f1,
\f3pmFreeMetricSpec\f1 \- uniform metric specification parser
.SH "C SYNOPSIS"
.ft 3
#include <pcp/pmapi.h>
.sp
.ad l
.hy 0
.in +8n
.ti -8n
int pmParseMetricSpec(const char *\fIstring\fP, int \fIisarch\fP, char\ *\fIsource\fP, pmMetricSpec\ **\fIrsltp\fP, char\ **\fIerrmsg\fP);
.br
.ti -8n
void pmFreeMetricSpec(pmMetricSpec *\fIrslt\fP);
.sp
.in
.hy
.ad
cc ... \-lpcp
.ft 1
.SH DESCRIPTION
.B pmParseMetricSpec
accepts a
.B string
specifying the name of a PCP performance metric, and optionally
the source (either a hostname or a PCP archive log filename)
and instances for that metric.
The syntax is described in
.BR PCPIntro (1).
.PP
If neither \fBhost\fR nor \fBarchive\fR component
of the metric specification is provided, the \fBisarch\fR
and \fBsource\fR arguments are used to fill in the returned
.B pmMetricSpec
structure.
.PP
The
.B pmMetricSpec
structure that is returned via
.B rsltp
represents the parsed
.B string
and has the following
declaration:
.PP
.nf
.ft CW
    typedef struct {
        int     isarch;      /* source type: 0 -> live host, 1 -> archive, 2 -> local context */
        char    *source;     /* name of source host or archive */
        char    *metric;     /* name of metric */
        int     ninst;       /* number of instances, 0 -> all */
        char    *inst[1];    /* array of instance names */
    } pmMetricSpec;
.fi
.PP
.B pmParseMetricSpec
returns 0 if the given
.B string
was successfully parsed.  In this case all the storage allocated by
.B pmParseMetricSpec
can be released by a single call to
.BR free (3C)
using the address returned from
.B pmMetricSpec
via
.BR rsltp .
The convenience macro
.B pmFreeMetricSpec
is a thinly disguised wrapper for
.BR free (3C).
.PP
.B pmParseMetricSpec
returns
.B PM_ERR_GENERIC
and a dynamically allocated error message string in
.BR errmsg ,
if the given
.B string
does not parse.  Be sure to
.BR free (3C)
the error message string in this situation.
.PP
In the case of an error,
.B rsltp
is undefined.
In the case of success,
.B errmsg
is undefined.
If
.B "rsltp->ninst"
is 0, then
.B "rsltp->inst[0]"
is undefined.
.SH SEE ALSO
.BR PMAPI (3)
and
.BR pmLookupName (3).