[systemd-devel] net stats per app

Lennart Poettering lennart at poettering.net
Wed Aug 24 06:42:11 PDT 2011


On Tue, 02.08.11 15:51, Daniel Wagner (wagi at monom.org) wrote:

> So my thinking is, instead of using the uid driver trick, I could use
> cgroups for collecting the network traffic. At least from the sub module
> description it seems to be the right spot to add a new statistic
> interface.

Yupp, that makes a lot of sense I'd say. For CPU accounting there's
already cpuacct. Adding a netacct cgroup controller would make a lot of
sense to me. (a hackish way to achieve this with existing tools might be
to use net_cls for this or so. dunno, might already be enough if ip
rules allows accounting.)

> A open question is how I get the whole thing persistent. So not each
> time when an application starts the counters begin at 0. My guts feeling
> systemd should take of this but I don't know if that is the right
> direction.

Hmm, you could simply precreate the cgroups and mark the tasks file with
+t (sticky bit). systemd won't remove the cgroup then after use. Or, we
could add a new switch "ControlGroupPersistant=yes" or so which would
set +t automatically but systemd would still create the groups for you
(so that youdon't have to pre-create anything), but not delete them
anymore. Would that make sense?

(I have added this option now to the todo list, since it will make sense
for stuff like cpuacct where we are in the same boat)

> Is my idea completely broken or do you see any hope for this approach?

I think it makes a lot of sense.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list