Hi -
richard.wong.com wrote:
> Apologies if my questions are not straightforward.
It's a great question.
> 1. How does a PMDA interact with a specific container to fetch a metric, for
> instance "network.interface.up"?
At each fetch of a metric, for a client connection associated with a
named container, a participating pmda sends a message to a separate
root process called pmdaroot. It gets back a pid for the namespace.
The pmda saves its initial ns, then setns(2)'s to the target
container-pid's ns fds, fetches the values, then changes back.
See for example src/pmdas/linux/namespaces.c.
Note that not all pmdas participate, and those that participate may
not do so fully (for all metrics they serve), and even those metrics
that are container-aware-served by pmdas may not be
container-virtualized properly by the kernel.
Note also that pcp client connections are associated with container
names (basically substrings) within pmdas. The mapping to container
pids is done on-demand, every time, which has adverse performance
implications. See also
http://oss.sgi.com/bugzilla/show_bug.cgi?id=1110 .
> 2. Does this interaction differ between Docker containers vs. LXC containers
> vs. possible other types of containers?
The difference is hidden within pmdaroot. It guesses what kind of
container manager system is in effect by a fuzzy match of the pcp
client-supplied container name substring, and then applies the
appropriate logic. For lxc, it parses the lxc-info program's output.
For docker, it parses the /var/lib/docker/containers file. See also
http://oss.sgi.com/bugzilla/show_bug.cgi?id=1109 .
> 3. Where does the code for this container metric collection live?
See src/pmdas/root/* for the code that performs container-name
enumeration and container-name to namespace-pid lookups. See the
libpcp_pmda (__pmda*RootPDUContainer functions) for the message
passing logic between an ordinary pmda and the pmdaroot.
- FChE
|