Mini-HOWTO: mini_snmpd, a small snmpd for embedded systems like OpenWrt

mini_snmpd is a GPL snmpd by Robert Ernst.

It doesn't include docs, so here are some starter docs. The OpenWrt version can be installed from the package manager, but it doesn't seem to include a startup script for init.d, so I'll try to whip one up here, as well.

First, you'll need command line access to the device, so if it's an OpenWrt router, install the dropbear ssh server, and log in via ssh. SSH in as root.

To see the help for mini_snmpd, use the -h option:

mini_snmpd -h

You should see:

usage: mini_snmpd [options]

-p, --udp-port nnn     set the UDP port to bind to (161)
-P, --tcp-port nnn     set the TCP port to bind to (161)
-c, --community nnn    set the community string (public)
-D, --description nnn  set the system description (empty)
-V, --vendor nnn       set the system vendor (empty)
-L, --location nnn     set the system location (empty)
-C, --contact nnn      set the system contact (empty)
-d, --disks nnn        set the disks to monitor (/)
-i, --interfaces nnn   set the network interfaces to monitor (lo)
-t, --timeout nnn      set the timeout for MIB updates (1 second)
-a, --auth             require authentication (thus SNMP version 2c)
-v, --verbose          verbose syslog messages 
-l, --licensing        print licensing info and exit
-h, --help             print this help and exit

The default values are in parens.

On a router, you usually want to see the traffic going through the network interfaces. Here's a run of mini_snmpd that exposed those values:

mini_snmpd -i eth0.1,wl0,br-lan

Your command line may differ, depending on your router and network configuration. Mine was OpenWrt on a Linksys WRT54g or gl.

Back on your desktop (or whatever computer will be querying for snmp stats), use the net-snmp tools to poll for data. I learned how in this tutorial, Simple SNMP with Linux, by Jason Philbrook.

Run this:

snmpwalk -v 1 -c public

That IP address is my router. -v means version, and -c means community name: version 1, community "public". mini_snmpd seems to ignore the community name, but it must be supplied. The output I got was:

iso. = ""
iso. = OID: iso.
iso. = Timeticks: (412) 0:00:04.12
iso. = ""
iso. = STRING: "OpenWrt"
iso. = ""
iso. = INTEGER: 3
iso. = INTEGER: 1
iso. = INTEGER: 2
iso. = INTEGER: 3
iso. = STRING: "eth0.1"
iso. = STRING: "wl0"
iso. = STRING: "br-lan"
iso. = INTEGER: 1
iso. = INTEGER: 1
iso. = INTEGER: 1
iso. = Counter32: 1758591601
iso. = Counter32: 3436817368
iso. = Counter32: 1913312114
iso. = Counter32: 122466684
iso. = Counter32: 6121670
iso. = Counter32: 110670073
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 85
iso. = Counter32: 0
iso. = Counter32: 4073775119
iso. = Counter32: 980016090
iso. = Counter32: 2726650206
iso. = Counter32: 112229579
iso. = Counter32: 6270244
iso. = Counter32: 120445972
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 0
iso. = Counter32: 11015
iso. = Counter32: 0
iso. = Timeticks: (748634215) 86 days, 15:32:22.15

The first part is the object ID (OID), the second part is the data type, and the third part (after the colon) is the value. The OID is like a path to a value. What are these values? There's a database for them, and this page will show you the names for the network counters at iso.

That site has a ton of OIDs in it.

Armed with this knowledge, you should be able to program Cacti or MRTG to extract data from your router and graph it.

An init.d for OpenWrt

The old version of OpenWrt I'm using didn't create a script in init.d for me. So here's an init.d script, /etc/init.d/mini_snmpd:

#!/bin/sh /etc/rc.common
# Copyright (C) 2006

start () {
	mini_snmpd -i eth0.1,wl0,br-lan &

stop() {
	killall -9 mini_snmpd

It's based on init.d/cron

You also need to run this:

cd /etc/rc.d/
ln -s /etc/init.d/mini_snmpd S50mini_snmpd
/etc/init.d/mini_snmp start

That creates a symlink to cause mini_snmpd to start on boot. Then it starts the daemon. You can now log out of the router.