Skip to content

Commit

Permalink
netlink plugin: Report rx_nohandler stats
Browse files Browse the repository at this point in the history
Added metric for new counter from Linux kernel version 4.6+.

Issue: collectd#2510
  • Loading branch information
rpv-tomsk authored and nmdayton committed Jan 16, 2019
1 parent 3fc32f7 commit 174889a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions configure.ac
Expand Up @@ -3721,6 +3721,18 @@ if test "x$with_libmnl" = "xyes"; then
[[#include <linux/if_link.h>]]
)
AC_CHECK_MEMBERS([struct rtnl_link_stats.rx_nohandler],
[],
[],
[[#include <linux/if_link.h>]]
)
AC_CHECK_MEMBERS([struct rtnl_link_stats64.rx_nohandler],
[],
[],
[[#include <linux/if_link.h>]]
)
AC_CHECK_LIB([mnl], [mnl_nlmsg_get_payload],
[with_libmnl="yes"],
[with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
Expand Down
11 changes: 11 additions & 0 deletions src/netlink.c
Expand Up @@ -56,6 +56,7 @@ struct ir_link_stats_storage_s {
uint64_t tx_dropped;
uint64_t multicast;
uint64_t collisions;
uint64_t rx_nohandler;

uint64_t rx_length_errors;
uint64_t rx_over_errors;
Expand Down Expand Up @@ -253,6 +254,10 @@ static void check_ignorelist_and_submit(const char *dev,
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);
#if defined(HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER) || \
defined(HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER)
submit_one(dev, "if_rx_nohandler", NULL, stats->rx_nohandler);
#endif

submit_one(dev, "if_rx_errors", "length", stats->rx_length_errors);
submit_one(dev, "if_rx_errors", "over", stats->rx_over_errors);
Expand Down Expand Up @@ -304,6 +309,9 @@ static void check_ignorelist_and_submit64(const char *dev,
struct ir_link_stats_storage_s s;

COPY_RTNL_LINK_STATS(&s, stats);
#ifdef HAVE_STRUCT_RTNL_LINK_STATS64_RX_NOHANDLER
COPY_RTNL_LINK_VALUE(&s, stats, rx_nohandler);
#endif

check_ignorelist_and_submit(dev, &s);
}
Expand All @@ -314,6 +322,9 @@ static void check_ignorelist_and_submit32(const char *dev,
struct ir_link_stats_storage_s s;

COPY_RTNL_LINK_STATS(&s, stats);
#ifdef HAVE_STRUCT_RTNL_LINK_STATS_RX_NOHANDLER
COPY_RTNL_LINK_VALUE(&s, stats, rx_nohandler);
#endif

check_ignorelist_and_submit(dev, &s);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.db
Expand Up @@ -111,6 +111,7 @@ if_octets rx:DERIVE:0:U, tx:DERIVE:0:U
if_packets rx:DERIVE:0:U, tx:DERIVE:0:U
if_rx_dropped value:DERIVE:0:U
if_rx_errors value:DERIVE:0:U
if_rx_nohandler value:DERIVE:0:U
if_rx_octets value:DERIVE:0:U
if_rx_packets value:DERIVE:0:U
if_tx_dropped value:DERIVE:0:U
Expand Down

0 comments on commit 174889a

Please sign in to comment.