MCPcopy Create free account
hub / github.com/apache/impala / ReadProcNetDevLine

Method ReadProcNetDevLine

be/src/util/system-state-info.cc:181–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181void SystemStateInfo::ReadProcNetDevLine(
182 const StringPiece& dev_string, NetworkValues* result) {
183 StringPiece sp(dev_string);
184 // Lines can have leading whitespace
185 StripWhiteSpace(&sp);
186
187 // Initialize result to 0 to simplify error handling below
188 memset(result, 0, sizeof(*result));
189
190 // Don't include the loopback interface
191 if (sp.starts_with("lo:")) return;
192
193 int colon_idx = sp.find_first_of(':');
194 if (colon_idx == StringPiece::npos) {
195 KLOG_EVERY_N_SECS(WARNING, 60) << "Failed to parse interface name in line: "
196 << sp.as_string();
197 return;
198 }
199
200 ReadIntArray(sp.substr(colon_idx + 1), NUM_NET_VALUES, result);
201}
202
203void SystemStateInfo::AddNetworkValues(const NetworkValues& a, NetworkValues* b) {
204 for (int i = 0; i < NUM_NET_VALUES; ++i) (*b)[i] += a[i];

Callers

nothing calls this directly

Calls 6

ReadIntArrayFunction · 0.85
starts_withMethod · 0.80
as_stringMethod · 0.80
substrMethod · 0.80
StripWhiteSpaceFunction · 0.50
find_first_ofMethod · 0.45

Tested by

no test coverage detected