]> granicus.if.org Git - sysstat/commitdiff
Changed network counters (used by sar -n {DEV | EDEV }) to
authorseb <seb@kluane.home>
Mon, 10 Dec 2012 20:27:46 +0000 (21:27 +0100)
committerseb <seb@kluane.home>
Mon, 10 Dec 2012 20:27:46 +0000 (21:27 +0100)
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
activity.c
rd_stats.c
rd_stats.h

diff --git a/CHANGES b/CHANGES
index dedd0e56c1ae16c80ee42c6307bb02e2ae6df08e..77f9167a95f70bd6838d85b6b1b5f2a67f162b29 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
 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.
@@ -13,7 +17,7 @@ xxxx/xx/xx: Version 10.1.3 - Sebastien Godard (sysstat <at> orange.fr)
          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)
index 2cbadb6bd78c4605f2c32ada9ce2c9eab83ff163..58e258b9d60884393a4749027d3328dee26f32b4 100644 (file)
@@ -415,7 +415,7 @@ struct activity disk_act = {
 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,
@@ -446,7 +446,7 @@ struct activity net_dev_act = {
 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,
index 721807c058dff69e26316cfbb2bce411e88c6408..3e4782499bf8cd2df5cc4bc25ee936210dca8491 100644 (file)
@@ -711,8 +711,8 @@ void read_net_dev(struct stats_net_dev *st_net_dev, int nbr)
                        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,
@@ -759,8 +759,8 @@ void read_net_edev(struct stats_net_edev *st_net_edev, int nbr)
                        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,
index ee89b5ab7a8afbcb1464f16fe39668541279a3b0..57a76a55344c286270efb09dac944c60103ac973 100644 (file)
@@ -220,30 +220,30 @@ struct stats_disk {
 
 /* 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))