unsigned long long to keep in sync with current kernels.
Keep in sync with recent kernels (3.7rc8 used here): Now use
unsigned long long for network statistics.
WARNING: This breaks compatibility with older sar data
files format for network statistics.
Mail from Matthew Hall (matthew.hall@ecsc.co.uk) 15/12/2011:
I've spotted an issue with sadc when values in /proc/net/dev are greater
than
4294967295, in that in rd_stats.h all values in
stats_net_dev/stats_net_edev are unsigned long, but it *seems* that for
a while at least (earliest reference I can see is to 2002 [1]), that
values for (rx|tx)_(bytes|packets) are unsigned long long (this is the
format ifconfig from net-tools uses).
I've attached a sample of my /proc/net/dev (for reference) and a patch
for the 9.0.6.1 version of sysstat (also applies against 10.0.2 with
minor fuzz from patch) which converts lu to llu for these counters.
I've not looked much further into it, since this solves my particular
problem, but I expect it's not the 'correct' solution as I can see in
/usr/include/linux/if_link.h that rx_bytes is a '__u32' for x86, and
'__u64' for x86_64 - so it's probably not portable across different
architectures. There's likely some more work to be done to have
different format structs of stats_net_dev depending on arch.
Changes:
xxxx/xx/xx: Version 10.1.3 - Sebastien Godard (sysstat <at> orange.fr)
+ * Changed network counters (used by sar -n {DEV | EDEV }) to
+ unsigned long long to keep in sync with current kernels.
+ WARNING: This breaks compatibility with older sar data
+ files format for network statistics.
* [Peter Schiffer]: Added option -y to iostat. This option
prevents iostat from displaying its first report with
statistics since system boot.
restart, XML output file from sadf -x has no boot elements.
* Remove heading spaces in softirq names displayed by mpstat
for easier reading.
- * Cosmetic fixes in configure script.
+ * Fixed wrong command execution syntax in configure script.
* iostat manual page updated.
2012/10/06: Version 10.1.2 - Sebastien Godard (sysstat <at> orange.fr)
struct activity net_dev_act = {
.id = A_NET_DEV,
.options = AO_COLLECTED,
- .magic = ACTIVITY_MAGIC_BASE,
+ .magic = ACTIVITY_MAGIC_BASE + 1,
.group = G_DEFAULT,
#ifdef SOURCE_SADC
.f_count = wrap_get_iface_nr,
struct activity net_edev_act = {
.id = A_NET_EDEV,
.options = AO_COLLECTED,
- .magic = ACTIVITY_MAGIC_BASE,
+ .magic = ACTIVITY_MAGIC_BASE + 1,
.group = G_DEFAULT,
#ifdef SOURCE_SADC
.f_count = wrap_get_iface_nr,
strncpy(iface, line, MINIMUM(pos, MAX_IFACE_LEN - 1));
iface[MINIMUM(pos, MAX_IFACE_LEN - 1)] = '\0';
sscanf(iface, "%s", st_net_dev_i->interface); /* Skip heading spaces */
- sscanf(line + pos + 1, "%lu %lu %*u %*u %*u %*u %lu %lu %lu %lu "
- "%*u %*u %*u %*u %*u %lu",
+ sscanf(line + pos + 1, "%llu %llu %*u %*u %*u %*u %llu %llu %llu %llu "
+ "%*u %*u %*u %*u %*u %llu",
&st_net_dev_i->rx_bytes,
&st_net_dev_i->rx_packets,
&st_net_dev_i->rx_compressed,
strncpy(iface, line, MINIMUM(pos, MAX_IFACE_LEN - 1));
iface[MINIMUM(pos, MAX_IFACE_LEN - 1)] = '\0';
sscanf(iface, "%s", st_net_edev_i->interface); /* Skip heading spaces */
- sscanf(line + pos + 1, "%*u %*u %lu %lu %lu %lu %*u %*u %*u %*u "
- "%lu %lu %lu %lu %lu",
+ sscanf(line + pos + 1, "%*u %*u %llu %llu %llu %llu %*u %*u %*u %*u "
+ "%llu %llu %llu %llu %llu",
&st_net_edev_i->rx_errors,
&st_net_edev_i->rx_dropped,
&st_net_edev_i->rx_fifo_errors,
/* Structure for network interfaces statistics */
struct stats_net_dev {
- unsigned long rx_packets __attribute__ ((aligned (8)));
- unsigned long tx_packets __attribute__ ((aligned (8)));
- unsigned long rx_bytes __attribute__ ((aligned (8)));
- unsigned long tx_bytes __attribute__ ((aligned (8)));
- unsigned long rx_compressed __attribute__ ((aligned (8)));
- unsigned long tx_compressed __attribute__ ((aligned (8)));
- unsigned long multicast __attribute__ ((aligned (8)));
- char interface[MAX_IFACE_LEN] __attribute__ ((aligned (8)));
+ unsigned long long rx_packets __attribute__ ((aligned (16)));
+ unsigned long long tx_packets __attribute__ ((aligned (16)));
+ unsigned long long rx_bytes __attribute__ ((aligned (16)));
+ unsigned long long tx_bytes __attribute__ ((aligned (16)));
+ unsigned long long rx_compressed __attribute__ ((aligned (16)));
+ unsigned long long tx_compressed __attribute__ ((aligned (16)));
+ unsigned long long multicast __attribute__ ((aligned (16)));
+ char interface[MAX_IFACE_LEN] __attribute__ ((aligned (16)));
};
#define STATS_NET_DEV_SIZE (sizeof(struct stats_net_dev))
/* Structure for network interface errors statistics */
struct stats_net_edev {
- unsigned long collisions __attribute__ ((aligned (8)));
- unsigned long rx_errors __attribute__ ((aligned (8)));
- unsigned long tx_errors __attribute__ ((aligned (8)));
- unsigned long rx_dropped __attribute__ ((aligned (8)));
- unsigned long tx_dropped __attribute__ ((aligned (8)));
- unsigned long rx_fifo_errors __attribute__ ((aligned (8)));
- unsigned long tx_fifo_errors __attribute__ ((aligned (8)));
- unsigned long rx_frame_errors __attribute__ ((aligned (8)));
- unsigned long tx_carrier_errors __attribute__ ((aligned (8)));
- char interface[MAX_IFACE_LEN] __attribute__ ((aligned (8)));
+ unsigned long long collisions __attribute__ ((aligned (16)));
+ unsigned long long rx_errors __attribute__ ((aligned (16)));
+ unsigned long long tx_errors __attribute__ ((aligned (16)));
+ unsigned long long rx_dropped __attribute__ ((aligned (16)));
+ unsigned long long tx_dropped __attribute__ ((aligned (16)));
+ unsigned long long rx_fifo_errors __attribute__ ((aligned (16)));
+ unsigned long long tx_fifo_errors __attribute__ ((aligned (16)));
+ unsigned long long rx_frame_errors __attribute__ ((aligned (16)));
+ unsigned long long tx_carrier_errors __attribute__ ((aligned (16)));
+ char interface[MAX_IFACE_LEN] __attribute__ ((aligned (16)));
};
#define STATS_NET_EDEV_SIZE (sizeof(struct stats_net_edev))