MCPcopy Create free account
hub / github.com/prometheus/procfs / newNetIPSocket

Function newNetIPSocket

net_ip_socket.go:76–101  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

74)
75
76func newNetIPSocket(file string) (NetIPSocket, error) {
77 f, err := os.Open(file)
78 if err != nil {
79 return nil, err
80 }
81 defer f.Close()
82
83 var netIPSocket NetIPSocket
84 isUDP := strings.Contains(file, "udp")
85
86 lr := io.LimitReader(f, readLimit)
87 s := bufio.NewScanner(lr)
88 s.Scan() // skip first line with headers
89 for s.Scan() {
90 fields := strings.Fields(s.Text())
91 line, err := parseNetIPSocketLine(fields, isUDP)
92 if err != nil {
93 return nil, err
94 }
95 netIPSocket = append(netIPSocket, line)
96 }
97 if err := s.Err(); err != nil {
98 return nil, err
99 }
100 return netIPSocket, nil
101}
102
103// newNetIPSocketSummary creates a new NetIPSocket{,6} from the contents of the given file.
104func newNetIPSocketSummary(file string) (*NetIPSocketSummary, error) {

Callers 2

newNetTCPFunction · 0.85
newNetUDPFunction · 0.85

Calls 2

parseNetIPSocketLineFunction · 0.85
ErrMethod · 0.80

Tested by

no test coverage detected