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 <pcp/pmapi.h>
11       #include <pcp/impl.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

DESCRIPTION

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

RETURN VALUE

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

SEE ALSO

78       pmcd(1), pmproxy(1),  pmchart(1),  __pmParseHostAttrsSpec(3),  PMAPI(3)
79       and pmNewContext(3).
80
81
82
83Performance Co-Pilot                  PCP                   PMPARSEHOSTSPEC(3)
Impressum