kaegi / netinfo Goto Github PK
View Code? Open in Web Editor NEWGroups network usage by process
License: MIT License
Groups network usage by process
License: MIT License
This is just the library I have been looking for.
But the install fails
[user@ubuntu-pc ~]$ cargo install netinfo
Updating registry `https://github.com/rust-lang/crates.io-index`
Installing netinfo v0.3.1
error: failed to compile `netinfo v0.3.1`, intermediate artifacts can be found at `/tmp/cargo-install.Iblw5QVaBaBv`
Caused by:
Package `pnet_macros v0.21.0` does not have these features: `with-syntex`
Hi,
I am using netinfo-ffi (C wrapper), but i think this is related here.
Sometimes when I call netinfo_stat_get_bytes_per_pid it return all bytes given for pid, but when I call netinfo_stat_get_bytes_per_attr for In and Out it returns 0 bytes.
Sometimes it works well sometimes not. (Return both all bytes and in and out too).
For easier explanation, here is my output from my example:
Pid 9873, Out: 330 B, In: 330 B, All: 660 B //330 + 330 = 660 good
Pid 14047, Out: 140 B, In: 997 B, All: 1137 B //140 + 997 = 660 good
Pid 20468, Out: 0 B, In: 0 B, All: 5156662 B //0 + 0 != 5156662 problem
And here is my example source code:
void get_net_stat(ni_netinfo netinfo)
{
ni_net_statistics stat;
memset(&stat, 0, sizeof(ni_net_statistics));
handle_error(netinfo_get_net_statistics(netinfo, &stat));
ni_pid* pids = 0;
uint32_t num_pids = 0;
handle_error(netinfo_stat_get_all_pids(stat, &pids, &num_pids));
for(uint32_t i = 0; i < num_pids; i++) {
uint64_t bytes_out = 1;
uint64_t bytes_in = 1;
uint64_t bytes_all = 1;
ni_inout inout = NETINFO_IOT_OUTGOING;
ni_transport_type transport_type = NULL;
handle_error(netinfo_stat_get_bytes_per_attr(stat, &pids[i], &inout, &transport_type, &bytes_out));
inout = NETINFO_IOT_INCOMING;
transport_type = NULL;
handle_error(netinfo_stat_get_bytes_per_attr(stat, &pids[i], &inout, &transport_type, &bytes_in));
handle_error(netinfo_stat_get_bytes_per_pid(stat, pids[i], &bytes_all));
printf("Pid %d, Out: %d B, In: %d B, All: %d B\n", pids[i], bytes_out, bytes_in, bytes_all);
}
handle_error(netinfo_free_pid_array(pids, num_pids));
handle_error(netinfo_free_stat(stat));
}
It's given the limitations of the library or cpu, so it misses filter, or where is the problem? Is there any way to solve it?
Hello,
Can you please create C interface for netinfo?
In order to use the library from other languages.
It would be great!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.