Contents

Entware snmpd

Contents

I’m setting up a router which as the option of using entware to extend the functionality. This is great, as I want to have snmpd running on the network device for monitoring and such.

After setting up entware, I installed the snmpd package.

1
opkg install snmpd

Easy-peasy. Well…not really. No sample config or start scripts are included in the package. Not a huge deal. Just needed to bodge some in place.

For a snmpd.conf let’s do this:

1
2
3
4
5
6
7
com2sec local default [PASSWORD]
group localgroup v2c local
access localgroup "" any noauth exact all all none
view all included .1 80
syslocation Vancouver, BC
syscontact [[email protected]]
dontLogTCPWrappersConnects yes

For a init script, let’s using this hacky snmpd script.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

## Custom user script for snmpd
## This script auto called after system boots
## First param is:
##  "start" (call at start entware),
##  "stop" (call before stop entware),
## Include you custom rules for iptables below:

case "$1" in
start)
        # start snmpd daemon
        if [ -f /opt/var/run/snmpd.pid ]'
        then                                                   
                echo "snmpd running...`cat /opt/var/run/snmpd.pid`"
        else                        
                /opt/sbin/snmpd -Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /opt/var/run/snmpd.pid -c /opt/etc/snmp/snmpd.conf
                echo "snmpd started"
        fi

        ;'
stop)
        # stop snmpd
        kill `pgrep snmpd`
        rm /opt/var/run/snmpd.pid
        echo "snmpd stopped"
        ;'
status)
        # status snmpd
        if [ -f /opt/var/run/snmpd.pid ]'
        then
                echo "snmpd running...`cat /opt/var/run/snmpd.pid`"
        else
                echo "snmpd stopped"
        fi
        ;'
*)
        echo "Usage: $0 {start|stop|status}"
        exit 1
        ;'
esac

As you can see in the start script, it uses a snmp user and group. So we should create those.

1
# adduser -s /bin/false -D -u 1161 snmp

Done!