1PMGETCONTEXTHOSTNAME(3) Library Functions Manual PMGETCONTEXTHOSTNAME(3)
2
3
4
6 pmGetContextHostName, pmGetContextHostName_r - return the hostname
7 associated with a Performance Co-Pilot context
8
10 #include <pcp/pmapi.h>
11
12 const char *pmGetContextHostName(int id);
13 char *pmGetContextHostName_r(int id, char *buf, int buflen);
14
15 cc ... -lpcp
16
18 Given a valid PCP context identifier previously created with pmNewCon‐
19 text(3) or pmDupContext(3), the pmGetContextHostName function returns
20 the hostname associated with id. The pmGetContextHostName_r function
21 does the same, but stores the result in a user-supplied buffer buf of
22 length buflen, which should have room for at least MAXHOSTNAMELEN
23 bytes.
24
25 If the context id is associated with an archive source of data, the
26 hostname returned is extracted from the archive label using
27 pmGetArchiveLabel(3).
28
29 For live contexts, an attempt will first be made to retrieve the host‐
30 name from the PCP collector system using pmFetch(3) with the pmcd.host‐
31 name metric. This allows client tools using this interface to retrieve
32 an accurate host identifier even in the presence of port forwarding and
33 tunnelled connections.
34
35 Should this not succeed, then a fallback method is used. For local
36 contexts - with local meaning any of DSO, ``localhost'' or Unix domain
37 socket connection - a hostname will be sought via gethostname(3). For
38 other contexts, the hostname extracted from the initial context host
39 specification will be used.
40
42 If id is not a valid PCP context identifier, the returned hostname is a
43 zero length string.
44
46 pmGetContextHostName returns a pointer to a static buffer, so the
47 returned value is only valid until the next call to pmGetContextHost‐
48 Name and hence is not thread-safe. Multi-threaded applications should
49 use pmGetContextHostName_r instead.
50
52 Environment variables with the prefix PCP_ are used to parameterize the
53 file and directory names used by PCP. On each installation, the file
54 /etc/pcp.conf contains the local values for these variables. The
55 $PCP_CONF variable may be used to specify an alternative configuration
56 file, as described in pcp.conf(5). Values for these variables may be
57 obtained programmatically using the pmGetConfig(3) function.
58
60 PCPIntro(1), PMAPI(3), gethostname(3), pmDupContext(3), pmFetch(3),
61 pmGetArchiveLabel(3), pmNewContext(3), pcp.conf(5) and pcp.env(5).
62
63
64
65Performance Co-Pilot PCP PMGETCONTEXTHOSTNAME(3)