pcp
[Top] [All Lists]

Re: PMDA interaction with containers

To: Richard Wong <richard.wong.com@xxxxxxxxx>
Subject: Re: PMDA interaction with containers
From: fche@xxxxxxxxxx (Frank Ch. Eigler)
Date: Wed, 23 Sep 2015 18:57:32 -0400
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CAP2pTW4G6Jt3YmLKbPw+ag4A9NH+bZA8CFqzZHtdXw=UHSSqNA@xxxxxxxxxxxxxx> (Richard Wong's message of "Tue, 22 Sep 2015 12:05:01 -0700")
References: <CAP2pTW4G6Jt3YmLKbPw+ag4A9NH+bZA8CFqzZHtdXw=UHSSqNA@xxxxxxxxxxxxxx>
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)
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

<Prev in Thread] Current Thread [Next in Thread>