#network #profile #usage #pid #nethogs

bin+lib netinfo

Groups network usage by process

8 releases (4 breaking)

Uses old Rust 2015

0.5.1 Sep 12, 2018
0.5.0 Sep 12, 2018
0.4.0 Apr 19, 2018
0.3.1 Jan 3, 2017
0.1.0 Nov 30, 2016

#986 in Filesystem

Download history 20/week @ 2023-10-30 8/week @ 2023-11-06 13/week @ 2023-11-13 14/week @ 2023-11-20 32/week @ 2023-11-27 11/week @ 2023-12-04 14/week @ 2023-12-11 9/week @ 2023-12-18 22/week @ 2023-12-25 4/week @ 2024-01-01 5/week @ 2024-01-08 11/week @ 2024-01-15 14/week @ 2024-01-22 20/week @ 2024-01-29 9/week @ 2024-02-05 33/week @ 2024-02-12

78 downloads per month
Used in netinfo-ffi

MIT license

57KB
864 lines

Netinfo

Netinfo is a Rust library and command line application that groups network usage by process. It works in a nethogs-like way, so you don't need a special kernel module.

In comparison to nethogs, it also supports UDP connections.

Because it heavily uses the /proc-filesystem, only Linux is supported at the moment.

Documentation

Crates.io

C Wrapper

How to use the library

Add this to your Cargo.toml:

[dependencies]
netinfo = 0.5.1

How to compile the binary

Install Rust and Cargo, then call:

# This will create the binary `~/.cargo/bin/netinfo`
$ cargo install netinfo

Running binaries

To avoid Permission denied errors, you will either have to run the progam as root or allow the program to capture the network traffic:

sudo setcap cap_net_raw,cap_net_admin=eip /path/to/your/bin

lib.rs:

This crate will group network usage per process. It uses a method similar to nethogs: All packets will be captured and their source/destination address are then used to match them to a process.

This matching process relies on the /proc file system, so it only works on Linux.

Because capturing the network traffic is not permittet for normal programs, you either have to run your binary as root or allow capturing with:

sudo setcap cap_net_raw,cap_net_admin=eip /path/to/your/bin

Dependencies

~3–5MB
~97K SLoC