So you wanna monitor bandwidth usage using MRTG and SNMPD.
Installing the ports tree.
Installing MRTG and SNMPD.
# Then copy the code below, and edit to this location: /usr/local/share/snmp/snmpd.conf
Starting SNMPD:
Configure MRTG using cfgmaker
/usr/local/www/data-dist/mrtg = The location you want at your webserver
/usr/local/www/data-dist/mrtg/mrtg.cfg = The location you want of your mrtg.cfg
Edit this to suite your needs. dumburk is the name of my machine. If you wanna change, you need to edit both snmpd.conf and edit cfgmaker command before run.
OK. Now everything should be setup right try run
Adding the following command to /etc/crontab will update mrtg-graphs every 5th minute.
This guide is a couple of years old, but still works great.
http://oss.oetiker.ch/mrtg/
http://www.net-snmp.org/
http://www.FreeBSD.org
Installing the ports tree.
Code:
portsnap fetch && portsnap extract && portsnap fetch update
Installing MRTG and SNMPD.
Code:
# Then install SNMPd port with:
cd /usr/ports/net-mgmt/net-snmp; make install
# Then install MRTG port with:
cd /usr/ports/net-mgmt/mrtg ; make install
# Then copy the code below, and edit to this location: /usr/local/share/snmp/snmpd.conf
Code:
###########################################################################
#
# /usr/local/share/snmp/snmpd.conf
#
###########################################################################
#
# snmpd.conf
#
# - created by the snmpconf configuration program
#
###########################################################################
# SECTION: System Information Setup
#
# This section defines some of the information reported in
# the "system" mib group in the mibII tree.
# syslocation: The [typically physical] location of the system.
# Note that setting this value here means that when trying to
# perform an snmp SET operation to the sysLocation.0 variable will make
# the agent return the "notWritable" error code. IE, including
# this token in the snmpd.conf file will disable write access to
# the variable.
# arguments: location_string
syslocation My Country
# syscontact: The contact information for the administrator
# Note that setting this value here means that when trying to
# perform an snmp SET operation to the sysContact.0 variable will make
# the agent return the "notWritable" error code. IE, including
# this token in the snmpd.conf file will disable write access to
# the variable.
# arguments: contact_string
syscontact Name - email@domain.com
###########################################################################
# SECTION: Access Control Setup
#
# This section defines who is allowed to talk to your running
# snmp agent.
# rocommunity: a SNMPv1/SNMPv2c read-only access community name
# arguments: community [default|hostname|network/bits] [oid]
rocommunity dumburk localhost
Starting SNMPD:
Code:
Add snmpd_enable= "YES" to /etc/rc.conf and save. Then type /usr/local/etc/rc.d/snmpd start
Configure MRTG using cfgmaker
Code:
cfgmaker --global 'WorkDir: /usr/local/www/data-dist/mrtg' --global 'Options[_]: growright,unknaszero' --output /usr/local/www/data-dist/mrtg.cfg dumburk@localhost
/usr/local/www/data-dist/mrtg = The location you want at your webserver
/usr/local/www/data-dist/mrtg/mrtg.cfg = The location you want of your mrtg.cfg
Edit this to suite your needs. dumburk is the name of my machine. If you wanna change, you need to edit both snmpd.conf and edit cfgmaker command before run.
OK. Now everything should be setup right try run
Code:
/usr/local/bin/mrtg /path/to/mrtg.cfg
Adding the following command to /etc/crontab will update mrtg-graphs every 5th minute.
Code:
*/5 * * * * root /usr/bin/env LANG=C /usr/local/bin/mrtg /path/to/mrtg.cfg --logging /var/log/mrtg.log
This guide is a couple of years old, but still works great.
http://oss.oetiker.ch/mrtg/
http://www.net-snmp.org/
http://www.FreeBSD.org