shanecode / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Add network interface speed information #250

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Proposal

Add the network interface spped (100 Mbps, 1000 Mbps...) in the structure 
returned by the psutil.network_io_counters(True) function

On what platforms would this be available?

Any

Proposed API

-

Are there existent implementations we can use as an example?

# python
# import statgrab
# statgrab.sg_get_network_iface_stats()
[{'duplex': 2, 'interface_name': 'lo', 'speed': 0, 'up': 1}, {'duplex': 0, 
'interface_name': 'eth0', 'speed': 100, 'up': 1}, {'duplex': 2, 
'interface_name': 'wlan0', 'speed': 0, 'up': 1}, {'duplex': 2, 
'interface_name': 'virbr0', 'speed': 0, 'up': 1}]

Please provide any additional information below.

-

Original issue reported on code.google.com by nicolash...@gmail.com on 30 Jan 2012 at 2:14

GoogleCodeExporter commented 9 years ago
This reminds me of issue 204 (get NICs ip/subnet/broadcast/gateway addresses) 
which we decided to reject:
http://code.google.com/p/psutil/issues/detail?id=204#c6

I believe this is pretty hard to implement on all platforms.
Also, the kind of network info you can extract change depending on the 
platform; as such it's not immediately clear what API this should have.
Last: is this really useful? IMO, it isn't (can't think of a use case).

Original comment by g.rodola on 30 Jan 2012 at 2:38

GoogleCodeExporter commented 9 years ago
I use it to display alerts in Glances (https://github.com/nicolargo/glances). 
For exemple, when the network bitrate of a 100 Mbps interface is higher than 70 
Mbps then the stat is displayed using a WARNING color.

In Glances v2.0, i want to replace StatGrab by PsUtil :)

Original comment by nicolash...@gmail.com on 30 Jan 2012 at 2:47

GoogleCodeExporter commented 9 years ago
Interesting (and Glances looks like a nice tool).
So exactly what info are you proposing to extract from the NICs?
Just the bitrate? What do 'duplex' and 'up' parameters represent?
Being these per-NIC info only we should provide a new function (!= current 
network_io_counters()).

Original comment by g.rodola on 30 Jan 2012 at 3:12

GoogleCodeExporter commented 9 years ago
I only use the maximum bitrate of the network interface.

I just create a wiki page for the Statgrab to PsUtil works: 
https://github.com/nicolargo/glances/wiki/Study:-replace-StatGrab-by-PSUtil

Nicolas

Original comment by nicolash...@gmail.com on 30 Jan 2012 at 3:17

GoogleCodeExporter commented 9 years ago
Marking it as 'accepted'.
Ideally we'd have a nics_info() function (or network_ifaces_info() in order to 
remain consistent with network_io_counters()) along these lines:

>>> psutil.nics_info()
{'lo':info(speed=100, up=True, duplex=2),
 'eth0':info(speed=100, up=True, duplex=2),
 ... }

Still have to look into implementation details on every platform though.

Original comment by g.rodola on 24 Feb 2013 at 10:32

GoogleCodeExporter commented 9 years ago
I created a separate hg branch for this and started with the Linux 
implementation committed as revision 60843072901f. 

Original comment by g.rodola on 3 Mar 2013 at 11:18

GoogleCodeExporter commented 9 years ago
psutil has been migrated from Google Code to Github (see: 
http://grodola.blogspot.com/2014/05/goodbye-google-code-im-moving-to-github.html
).
Please do NOT reply here but use this instead:
https://github.com/giampaolo/psutil/issues/250

Original comment by g.rodola on 26 May 2014 at 3:08