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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
|
'\"macro stdmacro
.\"
.\" Copyright (c) 2000 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 PMGENMAP 1 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmgenmap\f1 \- generate C code to simplify handling of performance metrics
.SH SYNOPSIS
\f3pmgenmap\f1
[\f2infile\f1]
.SH DESCRIPTION
.de CR
.ie t \f(CR\\$1\f1\\$2
.el \fI\\$1\f1\\$2
..
Given one or more lists of metric names in
.I infile
or on standard input,
.B pmgenmap
generates C declarations
and
.BR cpp (1)
macros suitable for use across the
Performance Metrics Programming Interface (PMAPI)
on standard output.
.PP
The declarations produced by
.B pmgenmap
simplify the coding for client applications using the PMAPI.
.PP
The input should consist of one or more lists of metric names of the form
.PP
.ft CR
.nf
.in +0.5i
listname {
metricname1 symbolname1
metricname2 symbolname2
...
}
.in
.fi
.ft 1
.PP
which will generate C and
.BR cpp (1)
declarations of the form
.PP
.ft CR
.nf
.in +0.5i
char *listname[] = {
#define symbolname1 0
"metricname1",
#define symbolname2 1
"metricname2",
...
};
.in
.fi
.ft 1
.PP
The array declarations produced are suitable as parameters to
.BR pmLookupName (3)
and the
.BR #define d
constants may be used to index the
.CR vset s
in the
.CR pmResult
structure returned by a
.BR pmFetch (3)
call.
.PP
Obviously,
.CR listname
must conform to the C identifier naming rules, each
.CR symbolname
must conform to the
.BR cpp (1)
macro naming rules, and each
.CR metricname
is expected to be a valid performance metrics name (see
.BR PMNS (5)
for more details).
.PP
The input may include
.BR sh -style
comment lines, i.e. with a `\f3#\f1' as the first non-blank character of a
line, and these are translated on output to either single line or multi-line C
comments in the K&R style.
For example, the input:
.sp
.PP
.ft CR
.nf
.in +0.5i
# leading block of multi-line comments
# initialization group
foo {
a.b.c ONE
d.e.f.g TWO
# embedded block of multi-lines
# comments and boring pad text
xx.yy.zz THREE
}
# trailing single line comment
.in
.fi
.ft 1
.sp
.PP
Produces the output:
.PP
.ft CR
.nf
.in +0.5i
/*
* leading block of multi-line comments
* initialization group
*/
char *foo[] = {
#define ONE 0
"a.b.c",
#define TWO 1
"d.e.f.g",
/*
* embedded block of multi-lines
* comments and boring pad text
*/
#define THREE 2
"xx.yy.zz",
};
/* trailing single line comment */
.in
.fi
.ft 1
.SH EXAMPLES
For brevity we have removed the error handling code, and assumed the chosen
metrics do not have multiple values.
.PP
The input file
.PP
.ft CR
.nf
.in +0.5i
mystats {
kernel.percpu.cpu.idle IDLE
kernel.percpu.cpu.sys SYS
kernel.percpu.cpu.user USER
hinv.ncpu NCPU
}
.in
.fi
.ft 1
.PP
produces the following C code, suitable for
.BR #include -ing
.PP
.ft CR
.nf
.in +0.5i
/*
* Performance Metrics Name Space Map
* Built by pmgenmap from the file
* mystats.metrics
* on Wed Dec 28 19:44:17 EST 1994
*
* Do not edit this file!
*/
char *mystats[] = {
#define IDLE 0
"kernel.percpu.cpu.idle",
#define SYS 1
"kernel.percpu.cpu.sys",
#define USER 2
"kernel.percpu.cpu.user",
#define NCPU 3
"hinv.ncpu",
};
.in
.fi
.ft 1
.PP
Using the code generated by
.BR pmgenmap ,
we are now able to easily obtain metrics from the Performance Metrics Collection
Subsystem (PMCS) as follows:
.PP
.ft CR
.nf
.in +0.5i
#define MAX_PMID 4
int trip = 0;
int numpmid = sizeof(mystats)/sizeof(mystats[0]);
double duration;
pmResult *resp;
pmResult *prev;
pmID pmidlist[MAX_PMID];
pmNewContext(PM_CONTEXT_HOST, "localhost");
pmLookupName(numpmid, mystats, pmidlist);
pmFetch(numpmid, pmidlist, &resp);
printf("%d CPUs: %d usr %d sys %d idle\n",
resp->vset[NCPU]->vlist[0].value.lval,
resp->vset[USER]->vlist[0].value.lval,
resp->vset[SYS]->vlist[0].value.lval,
resp->vset[IDLE]->vlist[0].value.lval);
.in
.fi
.ft 1
.PP
Some calls to ensure portability have been removed from the code above for the
sake of clarity \- the example above should not be used as a template for
programming.
In particular, the raw values of the metrics were used when
.BR pmLookupDesc (3)
should have been called to determine the semantics of each metric.
.PP
More complete examples that demonstrate the use of
.B pmgenmap
which may be used as a basis for program development are included in the
PCP demos, e.g.
.IR $PCP_DEMOS_DIR/pmclient .
.SH FILES
.TP 5
.I $PCP_VAR_DIR/pmns/*
default PMNS specification files
.SH PCP ENVIRONMENT
Environment variables with the prefix \fBPCP_\fP are used to parameterize
the file and directory names used by PCP.
On each installation, the
file \fI/etc/pcp.conf\fP contains the local values for these variables.
The \fB$PCP_CONF\fP variable may be used to specify an alternative
configuration file, as described in \fBpcp.conf\fP(5).
.SH SEE ALSO
.BR cpp (1),
.BR PMAPI (3),
.BR pmFetch (3),
.BR pmLookupName (3),
.BR pmNewContext (3),
.BR pcp.conf (5),
.BR pcp.env (5)
and
.BR PMNS (5).
.\" control lines for scripts/man-spell
.\" +ok+ EST MAX_PMID NCPU SYS hinv ing {from #include -ing}
.\" +ok+ ncpu {from hinv.ncpu}
.\" +ok+ yy zz {from xx.yy.zz}
.\" +ok+ {all below are variables from C code example}
.\" +ok+ listname metricname mystats
.\" +ok+ pmidlist prev
.\" +ok+ resp sizeof symbolname sys
|