Search code examples
linuxkernelsnmp

How do I see linux kernel SNMP counters?


The kernel has a bunch of SNMP counters it increments under various situations, and I want to get the current values on my system. I found nstat, but that does not show all the counters (even with the -z option). For example, I want to see the value of "XfrmInStateSeqError", which is incremented in net/xfrm/xfrm_input.c:

if (async && x->repl->check(x, skb, seq)) {
  XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR);
  goto drop_unlock;
}

The system in question is Ubuntu 12.04 running kernel 3.2.0.


Solution

  • On my Debian it is just not compiled with kernel :

    grep XFRM_STATISTICS /lib/modules/3.1.0-1-amd64/build/.config
    # CONFIG_XFRM_STATISTICS is not set
    

    hence no /proc/net/xfrm_stat

    i guess setting CONFIG_XFRM_STATISTICS and recompiling kernel will do it...