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

NAME

6       pmLookupName - translate performance metric names into PMIDs
7

C SYNOPSIS

9       #include <pcp/pmapi.h>
10
11       int pmLookupName(int numpmid, const char **namelist, pmID *pmidlist);
12
13       cc ... -lpcp
14

DESCRIPTION

16       Given  a list in namelist containing numpmid full pathnames for perfor‐
17       mance metrics from a Performance Metrics Name Space  (PMNS),  pmLookup‐
18       Name  returns  the  list  of  associated Performance Metric Identifiers
19       (PMIDs) via pmidlist.
20
21       The result from pmLookupName depends on  the  presence  of  any  lookup
22       failures, their severity and the number of metrics being looked up.
23
24       1.  If there are no lookup failures, the return value will be numpmid.
25
26       2.  If a fatal error is encountered, the return value will be less than
27           0.  For example PM_ERR_TOOSMALL, PM_ERR_NOPMNS or PM_ERR_IPC.
28
29       3.  If numpmid is greater than one and non-fatal error(s)  are  encoun‐
30           tered,  the  return  value  is the number of metric names that have
31           successfully been looked up (greater than or equal to zero and less
32           than or equal to numpmid).
33
34       4.  If  numpmid is one and a non-fatal error is encountered, the return
35           value is the error code (less than zero).
36
37       When errors are encountered, any metrics that cannot be looked  up  re‐
38       sult in the corresponding element of pmidlist being set to PM_ID_NULL.
39
40       The  slightly convoluted error protocol allows bulk lookups, then prob‐
41       ing for more error details in the case of a specific failure, as  shown
42       in the EXAMPLES section below.
43
44       Note that the error protocol guarantees there is a 1:1 relationship be‐
45       tween the elements of namelist and pmidlist, hence both  lists  contain
46       exactly  numpmid  elements.  For this reason, the caller is expected to
47       have pre-allocated a suitably sized array for pmidlist.
48

EXAMPLE

50       #include <pcp/pmapi.h>
51
52       #define NUMPMID (sizeof(names)/sizeof(const char *))
53       const char *names[] = {
54                      "sample.bin",
55                      "sample",
56                      "sample.bog",
57                      "sample.secret.bar",
58                      "sample.secret.bar.bad"
59                    };
60       pmID pmids[NUMPMID];
61
62       int
63       main(int argc, char **argv)
64       {
65           int   sts;
66           int   numpmid = NUMPMID;
67
68           pmNewContext(PM_CONTEXT_HOST, "local:");
69
70           sts = pmLookupName(numpmid, names, pmids);
71
72           if (sts < 0) {
73            fprintf(stderr, "pmLookupName failed: %s0, pmErrStr(sts));
74            exit(1);
75           }
76           if (sts != numpmid) {
77            /*
78             * some of the lookups failed ... report the reason(s)
79             */
80            int  i;
81
82            for (i = 0; i < numpmid; i++) {
83                if (pmids[i] != PM_ID_NULL) continue;
84                /* this one failed */
85                sts = pmLookupName(1, &names[i], &pmids[i]);
86                fprintf(stderr, "%s: lookup failed: %s0, names[i], pmErrStr(sts));
87            }
88            exit(1);
89           }
90
91           /* all good ... */
92           ...
93       }
94
95

DIAGNOSTICS

97       PM_ERR_TOOSMALL
98              numpmid must be at least 1
99
100       PM_ERR_NOPMNS
101              Failed to access a PMNS for operation.  Note that if the  appli‐
102              cation  hasn't  a  priori called pmLoadNameSpace(3) and wants to
103              use the distributed PMNS, then a call to  pmLookupName  must  be
104              made after the creation of a context (see pmNewContext(3)).
105
106       PM_ERR_NAME
107              namelist[0]  does  not  correspond to a valid metric name in the
108              PMNS.
109
110       PM_ERR_NONLEAF
111              namelist[0] refers to a node in the PMNS but it was not  a  leaf
112              node.
113
114       PM_ERR_*
115              Other  diagnostics  are for protocol failures when accessing the
116              distributed PMNS.
117

SEE ALSO

119       PMAPI(3), pmGetChildren(3), pmGetChildrenStatus(3), pmGetConfig(3), pm‐
120       LoadNameSpace(3),   pmNameID(3),   pmNewContext(3),   pcp.conf(5)   and
121       pcp.env(5).
122
123
124
125Performance Co-Pilot                  PCP                      PMLOOKUPNAME(3)
Impressum