Giter VIP home page Giter VIP logo

netinfo's People

Contributors

changspivey avatar hdhoang avatar kaegi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netinfo's Issues

`cargo install netinfo` failing

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`

Sometimes unsorted In and Out bytes per pid

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?

C interface

Hello,
Can you please create C interface for netinfo?
In order to use the library from other languages.

It would be great!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.