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

Function parseIPVSBackendStatus

ipvs.go:136–207  ·  view source on GitHub ↗
(file io.Reader)

Source from the content-addressed store, hash-verified

134}
135
136func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
137 var (
138 status []IPVSBackendStatus
139 scanner = bufio.NewScanner(file)
140 proto string
141 localMark string
142 localAddress net.IP
143 localPort uint16
144 err error
145 )
146
147 for scanner.Scan() {
148 fields := strings.Fields(scanner.Text())
149 if len(fields) == 0 {
150 continue
151 }
152 switch {
153 case fields[0] == "IP" || fields[0] == "Prot" || fields[1] == "RemoteAddress:Port":
154 continue
155 case fields[0] == "TCP" || fields[0] == "UDP":
156 if len(fields) < 2 {
157 continue
158 }
159 proto = fields[0]
160 localMark = ""
161 localAddress, localPort, err = parseIPPort(fields[1])
162 if err != nil {
163 return nil, err
164 }
165 case fields[0] == "FWM":
166 if len(fields) < 2 {
167 continue
168 }
169 proto = fields[0]
170 localMark = fields[1]
171 localAddress = nil
172 localPort = 0
173 case fields[0] == "->":
174 if len(fields) < 6 {
175 continue
176 }
177 remoteAddress, remotePort, err := parseIPPort(fields[1])
178 if err != nil {
179 return nil, err
180 }
181 weight, err := strconv.ParseUint(fields[3], 10, 64)
182 if err != nil {
183 return nil, err
184 }
185 activeConn, err := strconv.ParseUint(fields[4], 10, 64)
186 if err != nil {
187 return nil, err
188 }
189 inactConn, err := strconv.ParseUint(fields[5], 10, 64)
190 if err != nil {
191 return nil, err
192 }
193 status = append(status, IPVSBackendStatus{

Callers 1

IPVSBackendStatusMethod · 0.85

Calls 1

parseIPPortFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…