[systemd-devel] net stats per app

Daniel Wagner wagi at monom.org
Tue Aug 2 06:51:17 PDT 2011


Hi,

I would like to do network statistics per application. That is all
traffic generated by an instance of an application through its sockets
should be collected and stored persistently. There are a few sub
problems to solve.

Let's start with Android. They have added a driver [1] to Linux which
collects all traffic through a socket and collects them per UID. The
data is then exported through the /proc interface. Note: the framing
is not counted.

Consequently every Android application installed uses a different user.
Of course it is not possible to distinguish between two instances of one
application. That seems to be an acceptable solution for them.

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.

Then systemd would do the life cycle managment and moves applications
into the right cgroup.

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.

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

I have CC the ConnMan list because I hope to get this working on the
shine new Session API.

Thanks,
Daniel

[1]
http://android.git.kernel.org/?p=kernel/common.git;a=blob_plain;f=drivers/misc/uid_stat.c;hb=5aa381271da879daa63420a687ca8e1c4b00deb6


More information about the systemd-devel mailing list