D-Link DNS-320 Cacti Monitoring

A quickie post for setting up “snmpd” on a D-Link DNS-320 to allow monitoring from Cacti!

Assumes a working install of funplug and optware already exists 🙂

root@DNS320:# slacker -a nano

root@DNS320:# slacker -a net-snmp

root@DNS320:# mkdir /ffp/etc/snmp

root@DNS320:# nano -w /ffp/etc/snmp/snmpd.conf

…..edit snmpd.conf appropriately, at a minimum:

rocommunity     public
syslocation
syscontact      "[email protected]"

root@DNS320:# nano -w /ffp/start/snmpd.sh

…..edit snmpd.sh to:

#!/ffp/bin/sh

# PROVIDE: snmpd
# REQUIRE: LOGIN

conf_file=/ffp/etc/snmp/snmpd.conf
pid_file=/ffp/var/run/snmpd.pid

snmpd_flags="-A -p $pid_file -a -c $conf_file"

snmpd_start()
{
        if [ ! -r "$conf_file" ]; then
                echo "Error: Missing config file $conf_file"
                exit 1
        fi

        echo "Starting /ffp/sbin/snmpd $snmpd_flags"
        /ffp/sbin/snmpd $snmpd_flags
}

snmpd_stop()
{
        if [ -r "$pid_file" ]; then
                kill $(cat $pid_file) 2>/dev/null
        fi
}

snmpd_status()
{
        if [ -r $pid_file ]; then
                snmpd_pid=$(cat $pid_file)
                if pidof snmpd | grep -wq $snmpd_pid; then
                        echo "snmpd running: $snmpd_pid"
                else
                        echo "snmpd not running ($pid_file stale)"
                fi
        else
                echo "snmpd not running"
        fi
}case "$1" in
        start)
                snmpd_start
                ;;
        stop)
                snmpd_stop
                ;;
        restart)
                snmpd_stop
                sleep 2
                snmpd_start
                ;;
        status)
                snmpd_status
                ;;
        *)
                echo "Usage: $(basename $0) start|stop|restart|status"
                exit 1
                ;;
esac

root@DNS320:# chmod 755 /ffp/start/snmpd.sh

root@DNS320:# /ffp/start/snmpd.sh start

root@DNS320:# ps aux |grep snmpd

(snmpd should now be running)

D-Link DNS-320 can now be monitored from Cacti!

Thanks for reading,

Martyn Wendon