Step 1: Install SNMP using Ports
# cd /usr/ports/net-mgmt/net-snmp
# make && make install && make clean
Step 2: Add Two Lines into /etc/rc.conf
snmpd_enable="YES"
snmpd_flags="-a -Lsd -p /var/run/snmpd.pid"
# chmod 444 /usr/local/etc/rc.d/snmptrapd.sh
Step 3: Configure snmpd.conf
# snmpconf -i
a. Edit snmpd.conf
b. Choose : System Information Setup
c. You will get
1: The [typically physical] location of the system.
d. Fill up 1 and 2. Please pay attention to option 3
2: The contact information for the administrator
3: The proper value for the sysServices object.
e. When finish, back to main menu and choose 2.
f. Choose 3, a SNMPv1/SNMPv2c read-only access community name
h. Put in community name such as, my_host_1. This community string will be
used later
i. In hostname and network mask enter an IP address you're trying
to monitor. For example, 208.18.228.43 (assume this is your IP address).
j. Setup OID, leave blank
k. Back to menu
l. The IP address and port number that the agent will listen on.
Step 4: Generate configuration file.
# /usr/local/etc/rc.d/snmpd.sh start
Step 5: Install MRTG using ports
# cd /usr/ports/net-mgmt/mrtg
# make && make install && make clean
Step 6: Configuration file creation for MRTG
Note that the address 208.18.228.43 is artificial. You should use an real IP
address instead. Also, my_host_1 should be the community string you've just
configured.
# cfgmaker my_host_1@208.18.228.43 > /usr/local/etc/mrtg/mrtg.cfg
Step 7: Edit /usr/local/etc/mrtg/mrtg.cfg
It's quite likely that you won't like how the small graph looks by the default. (which is 100 x 400). This can be changed, however by modifying the Xsize and YSize directive. For example:
XSize[my_host_1]: 600
YSize[my_host_1]: 250
It's also desireable to "modify" the Workdir directive to something more realistic. A good Example WorkDir: /usr/local/www/data/mrtg
Step 8: Adding entry for the Cron
Job
# crontab -e
Insert
*/5 * * * * /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
Step 9: Create an Web Directory
for the Apache Directory (for example: create a directory called /usr/local/www/data/mrtg)
Don't forget to replace [my_host_1] with the community string that you've used.
Step 10. Web Server Configuration (optional) to Update the Apache directory with correct documentroot
After creating the cfg file under your current document root, this directory automatically pointing to the html file created by adding the appropriate "Directoryindex" in "/usr/local/etc/apache/httpd.conf" (assume that this is your web server configuration file location). Otherwise, log files and directory content is revealed (which maybe a security risk / cosmetic thing, depend on your circumstances)