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

NAME

6       __pmParseHostSpec, __pmUnparseHostSpec, __pmFreeHostSpec - uniform host
7       specification parser
8

C SYNOPSIS

10       #include "pmapi.h"
11       #include "libpcp.h"
12
13       int __pmParseHostSpec(const char *string, pmHostSpec **hostsp,
14               int *count, char **errmsg);
15       int __pmUnparseHostSpec(pmHostSpec *hosts, int count, char *string,
16               size_t size);
17       void __pmFreeHostSpec(pmHostSpec *hosts, int count);
18
19       cc ... -lpcp
20

CAVEAT

22       This documentation is intended for internal Performance Co-Pilot  (PCP)
23       developer use.
24
25       These  interfaces  are  not part of the PCP APIs that are guaranteed to
26       remain fixed across releases, and they may not  work,  or  may  provide
27       different semantics at some point in the future.
28

DESCRIPTION

30       __pmParseHostSpec  accepts  a  string  specifying the location of a PCP
31       performance metric collector daemon.  The syntax of the various formats
32       of  this  string is described in PCPIntro(1) where several examples are
33       also presented.
34
35       The syntax allows the initial pmcd(1) hostname to  be  optionally  fol‐
36       lowed by a list of port numbers, which will be tried in order when con‐
37       necting to pmcd on that host.  The portlist is separated from the host‐
38       name using a colon, and each port in the list is comma-separated.
39
40       In  addition,  one  or  more optional pmproxy(1) hosts can be specified
41       (currently, only one proxy host is supported  by  the  PCP  protocols).
42       These  are  separated from each other and from the pmcd component using
43       the @ character.  These may also be followed by an optional port  list,
44       using the same comma-separated syntax as before.
45
46       __pmParseHostSpec takes a null-terminated host specification string and
47       returns an array of pmHostSpec structures, where the  array  has  count
48       entries.
49
50       These pmHostSpec structures that are returned via hostsp represent each
51       individual host in the specification string and has the following  dec‐
52       laration:
53
54           typedef struct {
55               char    *name;       /* hostname (always valid) */
56               int     *ports;      /* array of host port numbers */
57               int     nports;      /* number of ports in host port array */
58           } pmHostSpec;
59
60       __pmUnparseHostSpec  performs  the inverse operation, creating a string
61       representation from a number of hosts structures.  Where the  count  of
62       structures  indicated by hosts is greater than one, the proxy syntax is
63       used to indicate a chain of proxied hosts.  The size  of  the  supplied
64       string buffer must be provided by the caller using the size parameter.
65

RETURN VALUE

67       If  the  given  string is successfully parsed __pmParseHostSpec returns
68       zero.  In this case the dynamic storage allocated by  __pmParseHostSpec
69       can  be released by calling __pmFreeHostSpec using the address returned
70       from __pmParseHostSpec via hosts.
71
72       __pmParseHostSpec returns PM_ERR_GENERIC and  a  dynamically  allocated
73       error message string in errmsg, if the given string does not parse, and
74       the user-supplied errmsg pointer is non-null.  Be sure to  free(3)  the
75       error message string in this situation.
76
77       In  the  case of an error, hosts is undefined.  In the case of success,
78       errmsg is undefined.
79
80       On success __pmUnparseHostSpec returns a positive value indicating  the
81       number of characters written into the supplied buffer.  However, if the
82       supplied buffer was too small, a negative status code of -E2BIG is  re‐
83       turned.
84

SEE ALSO

86       pmcd(1),  pmproxy(1),  pmchart(1),  __pmParseHostAttrsSpec(3), PMAPI(3)
87       and pmNewContext(3).
88
89
90
91Performance Co-Pilot                  PCP                   PMPARSEHOSTSPEC(3)
Impressum