PMDISCOVERSERVICES(3)

NAME
pmDiscoverServices - discover PCP services on the network

C SYNOPSIS
#include <pcp/pmapi.h>

int pmDiscoverServices(const char *service, const char *mechanism, char ***urls);

cc ... -lpcp

DESCRIPTION
Given a PCP service name, as identified by service, and using the type of discovery optionally specified in mechanism, pmDiscoverServices returns, via urls, a list of URLs representing the services discovered on the network.

service specifies the PCP service to be discovered. Currently, only PM_SERVER_SERVICE_SPEC is supported, which searches for pmcd(1) servers.

mechanism specifies the style of discovery to be used. Currently, only "avahi" is supported. This searches for services which are broadcasting using mDNS via avahi-daemon(8). mechanism may also be NULL, which means to use all available discovery mechanisms.

Normally, pmDiscoverServices will return the number of services discovered, else a value less than zero for an error. The value zero indicates that no services were discovered.

The resulting list of pointers, urls, and the values (the URLs) that the pointers reference will have been allocated by pmDiscoverServices with a single call to malloc(3C), and it is the responsibility of the pmDiscoverServices caller to free( urls) to release the space when it is no longer required.

When an error occurs, or no services are discovered, urls is undefined (no space will have been allocated, and so calling free(3C) is a singularly bad idea).

PCP ENVIRONMENT
Environment variables with the prefix PCP_ are used to parameterize the file and directory names used by PCP. On each installation, the file /etc/pcp.conf contains the local values for these variables. The $PCP_CONF variable may be used to specify an alternative configuration file, as described in pcp.conf(5). Values for these variables may be obtained programmatically using the pmGetConfig(3) function.

SEE ALSO
PMAPI(3), pmcd(1), pmfind(1), pmGetConfig(3), pcp.conf(5), pcp.env(5) and avahi-daemon(8).

DIAGNOSTICS

EOPNOTSUPP
    The specified mechanism is not supported.