-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix parsing of interface aliases in netdev linux #904
Conversation
172bedd
to
cc5415b
Compare
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the error string formatting.
collector/netdev_linux.go
Outdated
return nil, fmt.Errorf("invalid line in net/dev: %s", scanner.Text()) | ||
parts := procNetDevInterfaceRE.FindStringSubmatch(line) | ||
if len(parts) != 3 { | ||
return nil, fmt.Errorf("Couldn't get interface name, invalid line in net/dev: %q", line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collector/netdev_linux.go
Outdated
|
||
values := procNetDevFieldSep.Split(strings.TrimLeft(parts[2], " "), -1) | ||
if len(values) != headerLength { | ||
return nil, fmt.Errorf("Couldn't get values, invalid line in net/dev: %q", parts[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collector/netdev_linux.go
Outdated
return nil, fmt.Errorf("invalid line in net/dev: %s", scanner.Text()) | ||
parts := procNetDevInterfaceRE.FindStringSubmatch(line) | ||
if len(parts) != 3 { | ||
return nil, fmt.Errorf("Couldn't get interface name, invalid line in net/dev: %q", line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: start error strings lower-cased: https://github.com/golang/go/wiki/CodeReviewComments#error-strings
Very old kernels expose interface aliases as `foo0:0`, adjust the line parsing to handle these names. Signed-off-by: Ben Kochie <[email protected]>
👍 |
Very old kernels expose interface aliases as
foo0:0
, adjust the lineparsing to handle these names.
Signed-off-by: Ben Kochie [email protected]
Closes: #902