Anda di halaman 1dari 4

Setting up MRTG on FreeBSD

by empty 17 Nov 2008, 14:40 So you wanna monitor bandwidth usage using MRTG and SNMPD. Installing the ports tree. CODE: SELECT ALL portsnap fetch && portsnap extract && portsnap fetch update

Installing MRTG and SNMPD. CODE: SELECT ALL # 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: SELECT ALL ############################################################# ############## # # /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: SELECT ALL Add snmpd_enable= "YES" to /etc/rc.conf and save. Then type /usr/local/etc/rc.d/snmpd start

Configure MRTG using cfgmaker CODE: SELECT ALL 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: SELECT ALL /usr/local/bin/mrtg /path/to/mrtg.cfg

Adding the following command to /etc/crontab will update mrtg-graphs every 5th minute. CODE: SELECT ALL */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.

Anda mungkin juga menyukai