DNS 323 - Funplug 0.7 : Supervise your NAS thru SNMP

Contents[Hide]

dropcap-dns323-snmp

If you own a DNS-323, you may have noticed that there is no simple way to supervise it.

Hopefully, thanks to funplug it is possible to compile and install Net-SNMP on this NAS.

Once it is installed, your DNS-323 becomes a fully featured SNMP device. A lot of possibilities are then opened in term of management and supervision.

This article explains how to setup an operational net-SNMP agent on a DNS-323 NAS running funplug.

This will allow you to supervise your DNS-323 thru SNMP with supervision softwares like Nagios, Munin, ...

A pre-requisite is to have have fully prepared your DNS-323 with fun_plug 0.7 and adds-on and to have setup the DNS-323 compilation environment.

1. Compile Net-SNMP package

As net-SNMP is not available in any DNS-323 repository for fun_plug 0.7, we'll need to compile it.

This can be done quite easily, but it will take ages (more than 1 hour).

During the configuration phase, you'll need to enter few parameters. For both paths, make sure to place them under /ffp root.

# wget http://optimate.dl.sourceforge.net/project/net-snmp/net-snmp/5.7.2.1/net-snmp-5.7.2.1.tar.gz
# tar -zxvf net-snmp-5.7.2.1.tar.gz
# cd net-snmp-5.7.2.1
# autoreconf -i
# ./configure --prefix=/ffp
...
Default version of SNMP to use (3): 3
...
System Contact Information (@@no.where): This email address is being protected from spambots. You need JavaScript enabled to view it.
...
System Location (Unknown): LocationOfYourDNS323
...
Location to write logfile (/var/log/snmpd.log): /ffp/var/log/snmpd.log
...
Location to write persistent information (/var/net-snmp): /ffp/var/net-snmp
...
# make
# make install

Net-SNMP agent is now installed.

Configuration file has been created under /ffp/etc/snmpd.conf. Just check you get expected values for  :

  • rocommunity : read-only community name (should be public)
  • syslocation : location you've entered in the configuration
  • syscontact : email address you've entered in the configuration

2. Create Startup Script

When you compile Net-SNMP package, no startup script is declared.

So, we have to create a /ffp/start/snmpd.sh startup script, that will follow funplug startup script format.

Once the script is declared, we must start the snmpd daemon.

/ffp/start/snmpd.sh

#!/ffp/bin/sh
#
# SNMP agent startup script
#
# Installation instructions are available at
# http://bernaerts.dyndns.org/nas/313-dns325-ffp7-supervise-snmp-agent
#
# History :
#  25/06/2014, V1.0 - Creation by N. Bernaerts

# PROVIDE: snmpd
# REQUIRE: LOGIN


conf_file=/ffp/etc/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 1
  snmpd_start
  ;;
status)
  snmpd_status
  ;;
*)
  echo "Usage: $(basename $0) start|stop|restart|status"
  exit 1
  ;;
esac

# wget --no-check-certificate -O /ffp/start/snmpd.sh https://raw.githubusercontent.com/NicolasBernaerts/dns325-scripts/master/snmp/snmpd.sh
# chmod +x /ffp/start/snmpd.sh
# /ffp/start/snmpd.sh start

Your DNS-325 Net-SNMP daemon is now running.

It should start automatically at every boot.

3. Test new SNMP MIB

As Net-SNMP compilation has installed all SNMP tools, we can now test the new SNMP MIB from the DNS-323 console :

# snmpwalk -v1 -cpublic localhost 2>/dev/null
SNMPv2-MIB::sysDescr.0 = STRING: Linux NAS-NANTES 2.6.12.6-arm1 #47 Mon Nov 30 12:06:02 CST 2009 armv5tejl
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (147756) 0:24:37.56
SNMPv2-MIB::sysContact.0 = STRING: \"This email address is being protected from spambots. You need JavaScript enabled to view it.\"
SNMPv2-MIB::sysName.0 = STRING: NAS-NANTES
SNMPv2-MIB::sysLocation.0 = STRING: DNS-323 Nantes
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (8) 0:00:00.08
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
...

You are now ready to configure your favorite monitoring tool to give you some interesting activity graphs of your DNS-323.

 

Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus