It was kind of a surprise to find out that net-snmp uses various update-intervals for different mib-tree branches!

From my experience I know that it’s pretty common in all kinds of network equipment as switches, routers etc, to update SNMP agent counters (OID’s) in real time.

However, I noticed that, for instance on my Ubuntu 12.04 LTS box, the “ifTable” branch updated every 15 and the “ip” branch every 5 seconds by default. The FC_RTGraph screenshot below (one application of the FCMS suite) shows the result of the eth0 interface being polled every second.


Only a spike every 15 seconds!

It depends of course on whether a 15 seconds update interval suits your needs but in my case it did not and I decided to start “googling” for a way to modify this behavior. After some digging I found what I was looking for.

Here’s how you can change the update intervals

The net-snmp-agent.mib contains a table called “nsCacheTable ( which contains entries describing, quoting from the mib, “The length of time (in seconds) for which the data in this particular cache entry will remain valid”. In my case (default net-snmp installation) the table contained 16 entries.


A screen-shot of the nsCacheTable of my Linux box.

The first row of the table holds the “cache timeout” (15 seconds) of the interfaces table (ifTable – The second row configures the cache-timeout (5 seconds) of the “ip” table. Below is a fragment from the net-snmp MIB describing the child-nodes of the nsCacheEntry node:

MAX-ACCESS not-accessible
STATUS current
"The root OID of the data being cached."
::= { nsCacheEntry 1 }

nsCacheTimeout OBJECT-TYPE
MAX-ACCESS read-write
STATUS current
"The length of time (?in seconds) for which the data in
this particular cache entry will remain valid."
::= { nsCacheEntry 2 }

nsCacheStatus OBJECT-TYPE
SYNTAX NetsnmpCacheStatus
MAX-ACCESS read-write
STATUS current
"The current status of this particular cache entry.
Acceptable values for Set requests are 'enabled(1)',
'disabled(2)' or 'empty(3)' (to clear all cached data).
Requests to read the value of such an object will
return 'disabled(2)' through to 'expired(5)'."
::= { nsCacheEntry 3 }

The syntax of the nsCacheTimeout field is INTEGER and offers read-write access! I decided to give this a try and use the net-SNMP snmpset command to modify the nsCacheTimeout value for the “ifTable” on my Linux box.

snmpset -c private -v 1 i 1

The load on my server’s eth0 interface, polled every second, after the “set” command.

Using the FC-RTSet component to modify the nsCacheTimeout value

FC_RTSet (also part of the FCMS suite) makes it very easy to modify the nsCacheTimeout value for a mib table. Note that because the nsCacheTimeout node is not part of the mib-2 branch, you cannot use the “free trial” FCMS version but you need to buy a license. See the screenshot below:


Using FC_RTSet to update the nsCacheTimeout interval.

Additional observation

If the net-snmp daemon (snmpd) is restarted (or the system is booted) all update intervals return to their default values. So far I haven’t found a way to save the modified update values through snmp! As a workaround I have added a line to the /etc/rc.local script. This script is executed each time a system boots.

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Set the default cachetime for ifTable and ifXentry counters

sleep 10
snmpset -c private -v 1 localhost i 0

exit 0

The snmpset command “sets” the nsCacheTimeout of the ifTable branch to 0 seconds, which factually means “no caching” at all.

The “override” method in snmpd.conf

A reader of my article pointed me into another solution. He suggested to try the “override” method in the snmpd.conf file (command below) but this sadly didn’t work for me. I tried it but it’s either busted or “override” doesn’t mean what I think it means. The override value was indeed reflected in the cache table, but was not actually used. The graph was still refreshing at its old interval of 15 seconds.

override . integer 0

How useful was this explanation?
Please rate! 1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.67 out of 5)

Published by Paul van Bergen

Owner & founder of FineConnection and developer of FCMS.

1 Comment

  1. You do not need an init script to disable the cache. First configure a setEvent in your snmpd.conf which will set the nsCacheTimeout OID to 0:

    setEvent e_disable_cache -I = 0

    and set up a monitor, which will trigger the setEvent right after cold start:

    monitor -e e_disable_cache -I -u equuleus coldstart .


Leave a Comment

Your email address will not be published!