352 |
|
} |
353 |
|
|
354 |
|
void populate_net() { |
355 |
< |
int n, i; |
355 |
> |
int num_io, num_iface, i; |
356 |
|
sg_network_io_stats *io; |
357 |
|
sg_network_iface_stats *iface; |
358 |
|
|
359 |
< |
io = use_diffs ? sg_get_network_io_stats_diff(&n) |
360 |
< |
: sg_get_network_io_stats(&n); |
359 |
> |
io = use_diffs ? sg_get_network_io_stats_diff(&num_io) |
360 |
> |
: sg_get_network_io_stats(&num_io); |
361 |
|
if (io != NULL) { |
362 |
< |
for (i = 0; i < n; i++) { |
362 |
> |
for (i = 0; i < num_io; i++) { |
363 |
|
const char *name = io[i].interface_name; |
364 |
|
|
365 |
|
add_stat(STRING, &io[i].interface_name, |
383 |
|
} |
384 |
|
} |
385 |
|
|
386 |
< |
iface = sg_get_network_iface_stats(&n); |
386 |
> |
iface = sg_get_network_iface_stats(&num_iface); |
387 |
|
if (iface != NULL) { |
388 |
< |
for (i = 0; i < n; i++) { |
388 |
> |
for (i = 0; i < num_iface; i++) { |
389 |
|
const char *name = iface[i].interface_name; |
390 |
+ |
int had_io = 0, j; |
391 |
+ |
|
392 |
+ |
/* If there wasn't a corresponding io stat, |
393 |
+ |
add interface_name from here. */ |
394 |
+ |
if (io != NULL) { |
395 |
+ |
for (j = 0; j < num_io; j++) { |
396 |
+ |
if (strcmp(io[j].interface_name, |
397 |
+ |
name) == 0) { |
398 |
+ |
had_io = 1; |
399 |
+ |
break; |
400 |
+ |
} |
401 |
+ |
} |
402 |
+ |
} |
403 |
+ |
if (!had_io) { |
404 |
+ |
add_stat(STRING, &iface[i].interface_name, |
405 |
+ |
"net", name, "interface_name", NULL); |
406 |
+ |
} |
407 |
|
|
408 |
|
add_stat(INT, &iface[i].speed, |
409 |
|
"net", name, "speed", NULL); |