Net-SNMP on FreeBSD 7

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)

Overview:
 Step #1 - Download, Unzip, Untar, Configure, Compile and Install Net-SNMP
 Step #2 - Simple test of the SNMP logging server "snmptrapd"
 Step #3 - Create an “rc” script to start traplogd at boot time
 Step #4 - Configure the agent portion of snmp on the server "snmpd"

Step #1

Net-SNMP – SNMP tool collection (traplogd, snmpget, snmpwalk)

Home: 

 http://net-snmp.sourceforge.net

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)
cd /usr/src
fetch http://easynews.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.2.tar.gz

# Ungzip and Untar
tar xvf net-snmp-?.?.?.tar.gz

#
 Configure
cd net-snmp-?.?.?

# New way:
./configure --prefix=/usr/local --build=i386-src-freebsd7.0 --disable-debugging --with-mib-modules="if-mib" --with-python-modules --with-perl-modules --enable-embedded-perl --enable-shared --with-default-snmp-version=2 --with-sys-contact="
YourEmail@gmail.com" --with-sys-location="Earth" --with-zlib=/usr/local/lib --with-bzip2=/usr/local/lib --with-openssl=/usr/local/ssl/lib --with-logfile=/var/log/snmpd.log --with-persistent-directory=/var/net-snmp --enable-as-needed --enable-internal-md5 --enable-mfd-rewrites --enable-reentrant

# Compile & Install
make
make install
make clean

 

Step #2

Create a very basic "snmptrapd.conf"

Create some directories and edit the snmptrapd.conf:
cd /usr/local/etc
mkdir snmp
vi /usr/local/etc/snmp/snmptrapd.conf

 

Step #3

Create an “rc” script to start traplogd at boot time

# Create an “rc” script to start at boot time:
 

vi /usr/local/etc/rc.d/snmpd

vi /usr/local/etc/rc.d/snmptrapd

# Make the startup script executable:
chmod +x /usr/local/etc/rc.d/snmpd
chmod +x /usr/local/etc/rc.d/snmptrapd

# Edit rc.conf to allow remote syslog messages since you now allow remote traps!
vi /etc/rc.conf

# Edit syslog.conf and add "local7.*" to the "/var/log/messages" line:
vi /etc/syslog.conf
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err;local7.* /var/log/messages

# Restart Syslog
killall -HUP syslogd

# Notes
# MIBS are here: /usr/local/share/snmp/mibs

 

Step #4

Configure the agent portion of snmp on the server "snmpd"

# Edit snmpd.conf to suit your needs (Remember to fix /etc/rc.conf - snmpd_enable="YES" if you want the agent turned on - security risky!)
vi /etc/snmpd.config

# The agent section is not complete yet - use at your own risk
/usr/local/bin/snmpconf -G
/usr/local/bin/snmpconf -r none -g basic_setup

 

# Note: This section about the "agent" (snmpd) is not complete - My intention was to get the "server" (traplogd) running quickly.
#          Your help is welcomed here!