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.
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:
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 [CONTACT@EMAIL.ADDRESS] dontLogTCPWrappersConnects yes
For a init script, let’s using this hacky snmpd script.
#!/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.
# adduser -s /bin/false -D -u 1161 snmp
Done!