Autoloading MIB files in client SNMP configuration on Linux

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, May 09, 2012

Follow me on Twitter as @mattiasgeniar

You can download custom MIB files for most popular vendors (Cisco, Juniper, …) that allow you to talk SNMP to their device. In most cases, your commands will end up like this.

snmpwalk -v 2c -c community -m JUNIPER-COS-MIB 192.168.1.1

In the snmp-commands, you specify which MIB to load. If you’re using the same MIBS over and over again, this gets … annoying. So, add a MIB auto loader in the SNMP client configuration so it’s there for you to use every time.

First, check where the SNMP client config loads its configuration file from.

# net-snmp-config --snmpconfpath      
/etc/snmp:/usr/share/snmp:/usr/lib/snmp:/root/.snmp:/var/net-snmp

In that case, the /etc/snmp is included (this’ll be the case for nearly every snmp config). So, create a new file called /etc/snmp/snmp.conf (note: there may already be an snmpd.conf, that’s a different config!) and give it the following input.

mibs +JUNIPER-COS-MIB

If there’s already data in the snmp.conf, just add it at the bottom. You can simply insert new lines with extra MIBs to auto-load when using SNMP client commands.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.