Troubleshooting SNMP MIB Adoption Errors: Why Core MIBs Fail to Load in Ubuntu 12.04


2 views

When working with SNMP on Ubuntu 12.04 LTS, you might encounter a flood of "Cannot adopt OID" errors even with the distro's included MIBs. This manifests when running basic commands like:

snmpwalk -m ALL -v2c -c public localhost 1.3

The errors indicate that the SNMP agent is struggling to properly register OIDs from its own MIB modules:

Cannot adopt OID in UCD-SNMP-MIB: laIndex ::= { laEntry 1 }
Cannot adopt OID in NET-SNMP-AGENT-MIB: nsNotifyRestart ::= { netSnmpNotifications 3 }

Several factors can contribute to this behavior:

MIB Loading Order: The agent tries to register OIDs before their parent nodes exist in the OID tree. This sequencing problem is particularly common in Ubuntu's net-snmp package configuration.

Broken MIB File Paths: Check your MIB directories with:

snmpconf -g basic | grep mibs
net-snmp-config --default-mibdirs

Permission Issues: The agent might not have read access to MIB files. Verify with:

ls -l /usr/share/snmp/mibs/

Try these troubleshooting steps:

1. Explicitly set MIB directories:

export MIBS=ALL
export MIBDIRS=/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf

2. Adjust snmpd.conf:

# Add to /etc/snmp/snmpd.conf
persistentDir /var/lib/snmp
syscontact YourName 
syslocation ServerRoom
rocommunity public

3. Recompile MIBs with correct ordering:

sudo cp /usr/share/snmp/mibs/{UCD-SNMP-MIB.txt,NET-SNMP-AGENT-MIB.txt} /tmp
sudo mv /usr/share/snmp/mibs/UCD-SNMP-MIB.txt /usr/share/snmp/mibs/UCD-SNMP-MIB.txt.bak
sudo smilint -m /tmp/UCD-SNMP-MIB.txt > /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

Run snmpwalk with debug flags to see the registration attempts:

snmpwalk -Dmib_init -Dparse_mib -m ALL -v2c -c public localhost 1.3

This will show you exactly where the OID adoption fails during the MIB parsing process.

For a long-term solution, modify the net-snmp startup script:

# Edit /etc/default/snmpd
export MIBS=
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /var/run/snmpd.pid'

Then restart the service:

sudo service snmpd restart

These steps should resolve the MIB adoption issues while maintaining proper SNMP functionality.


After a fresh Ubuntu 12.04 LTS installation with SNMP packages, running a simple snmpwalk -m ALL -v2c -c public localhost 1.3 reveals numerous adoption errors like:

Cannot adopt OID in SQUID-MIB: cacheClients ::= { cacheProtoAggregateStats 15 }
Cannot adopt OID in NET-SNMP-EXTEND-MIB: nsExtendLineIndex ::= { nsExtendOutput2Entry 1 }
Cannot adopt OID in UCD-SNMP-MIB: laLoadFloat ::= { laEntry 6 }

These errors occur when SNMP tries to load MIBs with circular or improper OID references. The agent fails to establish proper parent-child relationships between OID nodes. Common scenarios include:

  • MIB files not properly placed in the search path
  • Incorrect MIB module dependencies
  • OID conflicts between different MIB files

First, check where your system looks for MIBs:

snmpwalk -Dmibinit 2>&1 | grep "mibdirs"

Sample output might reveal missing directories:

mibdirs: Searching /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf

For Ubuntu/Debian systems, this solution typically works:

sudo mkdir -p /usr/share/snmp/mibs
sudo apt-get install snmp-mibs-downloader
sudo download-mibs

Then edit /etc/snmp/snmp.conf:

mibs +ALL
mibdirs +/usr/share/snmp/mibs

For your own MIBs, ensure proper formatting and placement:

# Example MIB header structure
MY-MIB DEFINITIONS ::= BEGIN
IMPORTS
    MODULE-IDENTITY, OBJECT-TYPE, Integer32
        FROM SNMPv2-SMI
    DisplayString
        FROM SNMPv2-TC;

myMibModule MODULE-IDENTITY
    LAST-UPDATED "202301010000Z"
    ORGANIZATION "Example Inc."
    CONTACT-INFO "admin@example.com"
    DESCRIPTION  "Example MIB module"
    ::= { enterprises 12345 }

When standard solutions fail, try these debugging commands:

# Check MIB loading in detail
snmpwalk -Dmibinit,mibparse,mibload 2>&1 | less

# Test individual MIB loading
snmptranslate -m +MY-MIB -IR myObjectName

# Verify OID tree structure
snmptranslate -Tp -IR system

Remember that MIB files must be properly formatted and free from syntax errors. Tools like smilint can help validate your MIBs before deployment.