Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve /proc/net/dev parsing to include all edge cases #357

Merged
merged 1 commit into from
Apr 30, 2017

Conversation

ablagoev
Copy link
Contributor

@ablagoev ablagoev commented Apr 29, 2017

On some old Linux kernels /proc/net/dev has the following format:

Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:0 0    0    0    0     0          0         0   0   0    0    0    0     0       0          0
  eth0:0 0    0    0    0     0          0         0   0   0    0    0    0     0       0          0

This pull request (and commit respectively) broke the parsing of similar formats (where there is no space after ":"):

#317
654255b

I have improved the parsing a bit, so that all cases are handled properly, i.e:

eth1: bytes
eth1:bytes
eth1:0:bytes

Also created a test for all three cases.

@shirou shirou merged commit 9a4a916 into shirou:master Apr 30, 2017
@shirou
Copy link
Owner

shirou commented Apr 30, 2017

Hmm, I don't know this type of format. Thank you!

Could you tell me which version of linux and distro has this format? It is a very useful information to other people.

@ablagoev
Copy link
Contributor Author

Hey,

I've seen it on a couple of our machines. Oddly enough most of them are VMs. Alternatively, it might be a Centos quirk.

Distro Kernel
Centos 5.6 Linux 2.6.18-238.12.1.el5 x86_64 GNU/Linux
Centos 5.7 Linux 2.6.18-274.3.1.el5 x86_64 GNU/Linux
Centos 6.0 Linux 2.6.32-71.29.1.el6.x86_64 GNU/Linux
Centos 6.3 Linux 2.6.32-279.19.1.el6.x86_64 GNU/Linux

@shirou
Copy link
Owner

shirou commented Apr 30, 2017

Thank you so much. It will help someone later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants