Skip to content

Use 64-bit Darwin netstat counters#1319

Merged
discordianfish merged 1 commit intomasterfrom
superq/darwin_64_netdev
Apr 25, 2019
Merged

Use 64-bit Darwin netstat counters#1319
discordianfish merged 1 commit intomasterfrom
superq/darwin_64_netdev

Conversation

@SuperQ
Copy link
Member

@SuperQ SuperQ commented Apr 11, 2019

Avoid 32-bit counter rollovers.

Closes: #1318

@SuperQ SuperQ requested a review from discordianfish April 11, 2019 15:41
@SuperQ SuperQ force-pushed the superq/darwin_64_netdev branch from f0cdb97 to f26e607 Compare April 11, 2019 15:54
@SuperQ SuperQ changed the title Use 64-bit Darwin netstat counters [WIP] Use 64-bit Darwin netstat counters Apr 15, 2019
@SuperQ
Copy link
Member Author

SuperQ commented Apr 15, 2019

For some reason, this produces bad data.

@discordianfish
Copy link
Member

@SuperQ Any idea why? Maybe @matthiasr knows more?

@matthiasr
Copy link
Contributor

uh, no, how is it bad? some byte order problem? what do the darwin/macOS tools do?

@SuperQ
Copy link
Member Author

SuperQ commented Apr 24, 2019

@matthiasr I have no idea why it doesn't work.

Here's another implementation I found that might work better. Uses golang.org/x/sys/unix instead of C. https://github.com/Microsoft/ethr/blob/master/plt_darwin.go

@SuperQ SuperQ force-pushed the superq/darwin_64_netdev branch from f26e607 to b7b9b79 Compare April 24, 2019 13:41
Avoid 32-bit counter rollovers.

Signed-off-by: Ben Kochie <superq@gmail.com>
@SuperQ SuperQ force-pushed the superq/darwin_64_netdev branch from b7b9b79 to dd63036 Compare April 24, 2019 13:50
@SuperQ
Copy link
Member Author

SuperQ commented Apr 24, 2019

Ok, I tested this on my mac, seems to work better.

@SuperQ
Copy link
Member Author

SuperQ commented Apr 24, 2019

@pronoiac I found a better way to get the data. I've re-written this PR, can you try this again?

@SuperQ SuperQ changed the title [WIP] Use 64-bit Darwin netstat counters Use 64-bit Darwin netstat counters Apr 24, 2019
@SuperQ
Copy link
Member Author

SuperQ commented Apr 24, 2019

Ran a test on my mac, looks correct now:

Before:

node_network_receive_bytes_total{device="en0"} 1.094969344e+09
node_network_receive_bytes_total{device="lo0"} 6.580224e+06

After:

node_network_receive_bytes_total{device="en0"} 9.687110656e+09
node_network_receive_bytes_total{device="lo0"} 6.62016e+06

Rollover math looks right:

9687110656 % 2^32 = 1097176064

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in procfs? 😬

@SuperQ
Copy link
Member Author

SuperQ commented Apr 24, 2019

Hah, no, this is syscalls, not procfs parsing.

@discordianfish discordianfish merged commit 78b9eb9 into master Apr 25, 2019
@pronoiac
Copy link

I tested build 5550, and the data looks good at first glance! Thanks! 🎉

@mdlayher mdlayher deleted the superq/darwin_64_netdev branch June 10, 2019 14:48
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
Avoid 32-bit counter rollovers.

Signed-off-by: Ben Kochie <superq@gmail.com>
oblitorum pushed a commit to shatteredsilicon/node_exporter that referenced this pull request Apr 9, 2024
Avoid 32-bit counter rollovers.

Signed-off-by: Ben Kochie <superq@gmail.com>
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.

Darwin network metrics 32-bit?

4 participants