Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pmparsemetricspec(3) [centos man page]

PMPARSEMETRICSPEC(3)					     Library Functions Manual					      PMPARSEMETRICSPEC(3)

NAME
pmParseMetricSpec, pmFreeMetricSpec - uniform metric specification parser C SYNOPSIS
#include <pcp/pmapi.h> int pmParseMetricSpec(const char *string, int isarch, char *source, pmMetricSpec **rsltp, char **errmsg); void pmFreeMetricSpec(pmMetricSpec *rslt); cc ... -lpcp DESCRIPTION
pmParseMetricSpec accepts a string specifying the name of a PCP performance metric, and optionally the source (either a hostname or a PCP archive log filename) and instances for that metric. The syntax is described in PCPIntro(1). If neither host nor archive component of the metric specification is provided, the isarch and source arguments are used to fill in the re- turned pmMetricSpec structure. The pmMetricSpec structure that is returned via rsltp represents the parsed string and has the following declaration: typedef struct { int isarch; /* source type: 0 -> live host, 1 -> archive, 2 -> local context */ char *source; /* name of source host or archive */ char *metric; /* name of metric */ int ninst; /* number of instances, 0 -> all */ char *inst[1]; /* array of instance names */ } pmMetricSpec; pmParseMetricSpec returns 0 if the given string was successfully parsed. In this case all the storage allocated by pmParseMetricSpec can be released by a single call to free(3C) using the address returned from pmMetricSpec via rsltp. The convenience macro pmFreeMetricSpec is a thinly disguised wrapper for free(3C). pmParseMetricSpec returns PM_ERR_GENERIC and a dynamically allocated error message string in errmsg, if the given string does not parse. Be sure to free(3C) the error message string in this situation. In the case of an error, rsltp is undefined. In the case of success, errmsg is undefined. If rsltp->ninst is 0, then rsltp->inst[0] is undefined. SEE ALSO
PMAPI(3) and pmLookupName(3). Performance Co-Pilot PCP PMPARSEMETRICSPEC(3)

Check Out this Related Man Page

PMPARSEHOSTSPEC(3)					     Library Functions Manual						PMPARSEHOSTSPEC(3)

NAME
__pmParseHostSpec, __pmUnparseHostSpec, __pmFreeHostSpec - uniform host specification parser C SYNOPSIS
#include <pcp/pmapi.h> #include <pcp/impl.h> int __pmParseHostSpec(const char *string, pmHostSpec **hostsp, int *count, char **errmsg); int __pmUnparseHostSpec(pmHostSpec *hosts, int count, char *string, size_t size); void __pmFreeHostSpec(pmHostSpec *hosts, int count); cc ... -lpcp DESCRIPTION
__pmParseHostSpec accepts a string specifying the location of a PCP performance metric collector daemon. The syntax of the various formats of this string is described in PCPIntro(1) where several examples are also presented. The syntax allows the initial pmcd(1) hostname to be optionally followed by a list of port numbers, which will be tried in order when con- necting to pmcd on that host. The portlist is separated from the hostname using a colon, and each port in the list is comma-separated. In addition, one or more optional pmproxy(1) hosts can be specified (currently, only one proxy host is supported by the PCP protocols). These are separated from each other and from the pmcd component using the @ character. These may also be followed by an optional port list, using the same comma-separated syntax as before. __pmParseHostSpec takes a null-terminated host specification string and returns an array of pmHostSpec structures, where the array has count entries. These pmHostSpec structures that are returned via hostsp represent each individual host in the specification string and has the following declaration: typedef struct { char *name; /* hostname (always valid) */ int *ports; /* array of host port numbers */ int nports; /* number of ports in host port array */ } pmHostSpec; __pmUnparseHostSpec performs the inverse operation, creating a string representation from a number of hosts structures. Where the count of structures indicated by hosts is greater than one, the proxy syntax is used to indicate a chain of proxied hosts. The size of the supplied string buffer must be provided by the caller using the size parameter. RETURN VALUE
If the given string is successfully parsed __pmParseHostSpec returns zero. In this case the dynamic storage allocated by __pmParseHostSpec can be released by calling __pmFreeHostSpec using the address returned from __pmParseHostSpec via hosts. __pmParseHostSpec returns PM_ERR_GENERIC and a dynamically allocated error message string in errmsg, if the given string does not parse, and the user-supplied errmsg pointer is non-null. Be sure to free(3C) the error message string in this situation. In the case of an error, hosts is undefined. In the case of success, errmsg is undefined. On success __pmUnparseHostSpec returns a positive value indicating the number of characters written into the supplied buffer. However, if the supplied buffer was too small, a negative status code of -E2BIG is returned. SEE ALSO
pmcd(1), pmproxy(1), pmchart(1), __pmParseHostAttrsSpec(3), PMAPI(3) and pmNewContext(3). Performance Co-Pilot PCP PMPARSEHOSTSPEC(3)
Man Page

Featured Tech Videos