Skip to content

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

@wcc526

Description

@wcc526

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions