Changeset View
Changeset View
Standalone View
Standalone View
plugins/process/network/README.md
- This file was added.
1 | Per-process Network Usage Plugin | ||||
---|---|---|---|---|---|
2 | ================================ | ||||
3 | | ||||
4 | This plugin tries to track per-process network usage and feeds that back to | ||||
5 | ksysguard. Unfortunately, at the moment there is no unpriviledged API available | ||||
6 | for this information, so this plugin uses a small helper application to work | ||||
7 | around that. The helper uses libpcap to do packet capture. To do the packet | ||||
8 | capture it needs `cap_net_raw`, but nothing else. | ||||
9 | | ||||
10 | The helper only tracks TCP and UDP traffic, on IPv4 or IPv6 networks. Only the | ||||
11 | beginning of each packet is captured, so we only get the packet headers. These | ||||
12 | are processed to extract the source and destination IP address and port, which | ||||
13 | are matched with sockets and processes. | ||||
14 | | ||||
15 | The matching uses information parsed from `/proc/net/tcp{,6}` and | ||||
16 | `/proc/net/udp{,6}` for the sockets, which are mapped to processes by listing | ||||
17 | fds from `/proc/${pid}/fd/` and reading their symlink targets. Entries matching | ||||
18 | `socket:[${port}]` are used to track socket to process mapping. | ||||
19 | | ||||
20 | Once mapped, we store how much data was received for each process by | ||||
21 | accumulating the packet sizes for each socket. Every second this information is | ||||
22 | printed to the helper's stdout using the format | ||||
23 | `00:00:00|PID|0000|IN|000|OUT|000` or just `00:00:00` if there was no data that | ||||
24 | second. The helper's stdout is read and parsed by the network plugin and fed | ||||
25 | into ksysguard. |