Thursday, June 17, 2010

Change IF-MIB ifTable update frequency

CentOS 5.5 x86_64
net-snmp-5.3.2.2-9

When I run this command to try to get the updated data for InOctets:

[root@buildbox55-64bit SPECS]# while [ 1 ]; do snmpwalk -Os -c MYCOMMUNITY -v2c localhost .1.3.6.1.2.1.2.2.1.10.2; sleep 1; done


It seems that the data does not change in a 30 seconds interval:

ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7925145
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505
ifInOctets.2 = Counter32: 7927505


That's ok for "Standard" SNMP poller with a minimum polling interval > 60 seconds. Now if I need a very short interval, say 3 seconds or even 1 seconds. This does not work well.

The solution is to change the IFTABLE_CACHE_TIMEOUT in net-snmp source, here is mine:

/usr/src/redhat/SOURCES/net-snmp-5.3.2.2/agent/mibgroup/if-mib/ifTable/ifTable_data_access.h

Change:

#define IFTABLE_CACHE_TIMEOUT 30

to:

#define IFTABLE_CACHE_TIMEOUT 1


then rebuild net-snmp and upgrade it. now it's working as expected:

[root@buildbox55-64bit SPECS]# while [ 1 ]; do snmpwalk -Os -c MYCOMMUNITY -v2c localhost .1.3.6.1.2.1.2.2.1.10.2; sleep 1; done
ifInOctets.2 = Counter32: 8087029
ifInOctets.2 = Counter32: 8087421
ifInOctets.2 = Counter32: 8087519
ifInOctets.2 = Counter32: 8087911
ifInOctets.2 = Counter32: 8088219
ifInOctets.2 = Counter32: 8088475
ifInOctets.2 = Counter32: 8088633
ifInOctets.2 = Counter32: 8088731
ifInOctets.2 = Counter32: 8088889
ifInOctets.2 = Counter32: 8088987
ifInOctets.2 = Counter32: 8089145
ifInOctets.2 = Counter32: 8089243
ifInOctets.2 = Counter32: 8089401
ifInOctets.2 = Counter32: 8089499
ifInOctets.2 = Counter32: 8089657
ifInOctets.2 = Counter32: 8090085
ifInOctets.2 = Counter32: 8090670
ifInOctets.2 = Counter32: 8090768
ifInOctets.2 = Counter32: 8091268
ifInOctets.2 = Counter32: 8091426
ifInOctets.2 = Counter32: 8091524
ifInOctets.2 = Counter32: 8091682
ifInOctets.2 = Counter32: 8091780
ifInOctets.2 = Counter32: 8091938
ifInOctets.2 = Counter32: 8092036
ifInOctets.2 = Counter32: 8092194
ifInOctets.2 = Counter32: 8092382
ifInOctets.2 = Counter32: 8092604
ifInOctets.2 = Counter32: 8092702
ifInOctets.2 = Counter32: 8092924
ifInOctets.2 = Counter32: 8093022
ifInOctets.2 = Counter32: 8093180
ifInOctets.2 = Counter32: 8093278
ifInOctets.2 = Counter32: 8093436
ifInOctets.2 = Counter32: 8093692
ifInOctets.2 = Counter32: 8093790
ifInOctets.2 = Counter32: 8093948
ifInOctets.2 = Counter32: 8094046
ifInOctets.2 = Counter32: 8094452
ifInOctets.2 = Counter32: 8094550
ifInOctets.2 = Counter32: 8094708
ifInOctets.2 = Counter32: 8094806
ifInOctets.2 = Counter32: 8094964
ifInOctets.2 = Counter32: 8095062
ifInOctets.2 = Counter32: 8095220
ifInOctets.2 = Counter32: 8095318
ifInOctets.2 = Counter32: 8095476
ifInOctets.2 = Counter32: 8095818
ifInOctets.2 = Counter32: 8095976

1 comment:

  1. Don't need recompile source. Use this:
    snmpset -c public -v 2c 127.0.0.1 NET-SNMP-AGENT-MIB::nsCacheTimeout.1.3.6.1.2.1.2.2 i 1
    Of course you should have write access to this oid

    ReplyDelete