sg_get_network_io_stats, sg_get_network_io_stats_r, sg_get_network_io_stats_diff, sg_get_network_io_stats_diff_between, sg_free_network_io_stats, sg_network_io_compare_name — get network statistics


#include <statgrab.h>
sg_network_io_stats *fsfuncsg_get_network_io_stats(entries); 
size_t *entries;
sg_network_io_stats *fsfuncsg_get_network_io_stats_r(entries); 
size_t *entries;
sg_network_io_stats *fsfuncsg_get_network_io_stats_diff(entries); 
size_t *entries;
sg_network_io_stats *fsfuncsg_get_network_io_stats_diff_between(cur,  
const sg_network_io_stats *cur;
const sg_network_io_stats *last;
size_t *entries;
sg_error fsfuncsg_free_network_io_stats(data); 
sg_network_iface_stats *data;
int fsfuncsg_network_io_compare_name(va,  
const void *va;
const void *vb;


The sg_get_network_io_stats functions provide network interface I/O statistics on a per interface basis. All get- and diff-functions take an optional entries parameter, which points (when given) to a size_t to take the number of returned vector entries.

The sg_get_network_io_stats() and sg_get_network_io_stats_r() functions deliver the I/O-statistics since the interface has been attached to the system. The sg_get_network_io_stats_diff() and sg_get_network_io_stats_diff_between() deliver the difference between two calls of sg_get_network_io_stats() or sg_get_network_io_stats_r(), respectively.

sg_network_io_stats vectors received from sg_get_network_io_stats_r() or sg_get_network_io_stats_diff_between() must be freed using sg_free_network_io_stats() when not needed any more. The caller is responsible for doing it.

Additionally a support function for qsort(3) are available: sg_network_io_compare_name().

sg_get_network_io_stats returns the network traffic stored in the kernel which holds the amount of data transferred since device was attached. On some platforms, such as Solaris 7, this value is stored in a 32bit int, so wraps around when it reaches 4GB. Other platforms, such as Solaris 8, hold the value in a 64bit int, which wraps somewhere near 17 million terabytes. The sg_get_network_io_stats_diff() function and the sg_get_network_io_stats_diff_between() function care about these overflows and try to detect overflows when the diff is calculated.