When 64bit counters can be queried via netlink, query those instead of short 32bit counters.
Signed-off-by: Bruno Prémont <[email protected]> --- diff --git a/src/netlink.c b/src/netlink.c --- a/src/netlink.c 2014-01-26 09:09:23.532559941 +0100 +++ b/src/netlink.c 2014-04-06 00:02:57.359894383 +0200 @@ -275,13 +275,59 @@ static void check_ignorelist_and_submit } /* void check_ignorelist_and_submit */ +#ifdef IFLA_STATS64 +static void check_ignorelist_and_submit64 (const char *dev, + struct rtnl_link_stats64 *stats) +{ + + if (check_ignorelist (dev, "interface", NULL) == 0) + { + submit_two (dev, "if_octets", NULL, stats->rx_bytes, stats->tx_bytes); + submit_two (dev, "if_packets", NULL, stats->rx_packets, stats->tx_packets); + submit_two (dev, "if_errors", NULL, stats->rx_errors, stats->tx_errors); + } + else + { + DEBUG ("netlink plugin: Ignoring %s/interface.", dev); + } + + if (check_ignorelist (dev, "if_detail", NULL) == 0) + { + submit_two (dev, "if_dropped", NULL, stats->rx_dropped, stats->tx_dropped); + submit_one (dev, "if_multicast", NULL, stats->multicast); + submit_one (dev, "if_collisions", NULL, stats->collisions); + + submit_one (dev, "if_rx_errors", "length", stats->rx_length_errors); + submit_one (dev, "if_rx_errors", "over", stats->rx_over_errors); + submit_one (dev, "if_rx_errors", "crc", stats->rx_crc_errors); + submit_one (dev, "if_rx_errors", "frame", stats->rx_frame_errors); + submit_one (dev, "if_rx_errors", "fifo", stats->rx_fifo_errors); + submit_one (dev, "if_rx_errors", "missed", stats->rx_missed_errors); + + submit_one (dev, "if_tx_errors", "aborted", stats->tx_aborted_errors); + submit_one (dev, "if_tx_errors", "carrier", stats->tx_carrier_errors); + submit_one (dev, "if_tx_errors", "fifo", stats->tx_fifo_errors); + submit_one (dev, "if_tx_errors", "heartbeat", stats->tx_heartbeat_errors); + submit_one (dev, "if_tx_errors", "window", stats->tx_window_errors); + } + else + { + DEBUG ("netlink plugin: Ignoring %s/if_detail.", dev); + } + +} /* void check_ignorelist_and_submit64 */ +#endif + static int link_filter_cb (const struct nlmsghdr *nlh, void *args __attribute__((unused))) { struct ifinfomsg *ifm = mnl_nlmsg_get_payload (nlh); struct nlattr *attr; - struct rtnl_link_stats *stats = NULL; const char *dev = NULL; + struct rtnl_link_stats *stats = NULL; +#ifdef IFLA_STATS64 + struct rtnl_link_stats64 *stats64 = NULL; +#endif if (nlh->nlmsg_type != RTM_NEWLINK) { @@ -316,21 +362,39 @@ static int link_filter_cb (const struct mnl_attr_for_each (attr, nlh, sizeof (*ifm)) { - if (mnl_attr_get_type (attr) != IFLA_STATS) - continue; - - if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (*stats)) < 0) + if (mnl_attr_get_type (attr) == IFLA_STATS) { - ERROR ("netlink plugin: link_filter_cb: IFLA_STATS mnl_attr_validate2 failed."); - return MNL_CB_ERROR; + if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (*stats)) < 0) + { + ERROR ("netlink plugin: link_filter_cb: IFLA_STATS mnl_attr_validate2 failed."); + return MNL_CB_ERROR; + } + stats = mnl_attr_get_payload (attr); } - stats = mnl_attr_get_payload (attr); - - check_ignorelist_and_submit (dev, stats); - break; +#ifdef IFLA_STATS64 + else + if (mnl_attr_get_type (attr) == IFLA_STATS64) + { + struct rtnl_link_stats64 *stats64; + if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (*stats64)) < 0) + { + ERROR ("netlink plugin: link_filter_cb: IFLA_STATS64 mnl_attr_validate2 failed."); + return MNL_CB_ERROR; + } + stats64 = mnl_attr_get_payload (attr); + break; + } +#endif } - if (stats == NULL) +#ifdef IFLA_STATS64 + if (stats64) + check_ignorelist_and_submit64 (dev, stats64); + else +#endif + if (stats) + check_ignorelist_and_submit (dev, stats); + else { DEBUG ("netlink plugin: link_filter: No statistics for interface %s.", dev); return MNL_CB_OK; -- _______________________________________________ collectd mailing list [email protected] http://mailman.verplant.org/listinfo/collectd
