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

Read /proc/net files with a single read syscall. #1360

Closed
wcc526 opened this issue May 29, 2019 · 1 comment · Fixed by #1380
Closed

Read /proc/net files with a single read syscall. #1360

wcc526 opened this issue May 29, 2019 · 1 comment · Fixed by #1380

Comments

@wcc526
Copy link

wcc526 commented May 29, 2019

https://github.com/prometheus/node_exporter/blob/master/collector/tcpstat_linux.go#L116

Please read /proc/net files with a single read syscall.

shirou/gopsutil#361

`for scanner.Scan() {
parts := strings.Fields(scanner.Text())
if len(parts) == 0 {
continue
}
if len(parts) < 4 {
return nil, fmt.Errorf("invalid TCP stats line: %q", scanner.Text())
}

	if strings.HasPrefix(parts[0], "sl") {
		continue
	}
	st, err := strconv.ParseInt(parts[3], 16, 8)
	if err != nil {
		return nil, err
	}

	tcpStats[tcpConnectionState(st)]++
}`

which maybe lead high memory usage

@discordianfish
Copy link
Member

Very good point!

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

Successfully merging a pull request may close this issue.

2 participants