blog.up-link.ro
17Jun/100

FreeBSD: System Monitoring with MRTG

The Multi Router Traffic Grapher, or just simply MRTG, is free software for monitoring and measuring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form.

1. Installing Apache2 HTTP Server

Install Apache on the server you wish to display MRTG stats from:

cd /usr/ports/www/apache22
make install clean

To run Apache2 at system startup, append the following line to /etc/rc.conf :

apache22_enable="YES"

Start Apache2, enter:

/usr/local/etc/rc.d/apache22 start

NOTE: Apache2.2 wants to load an Accept Filter and if you don't load accf_http module on startup, you will get an error everytime you start apache. Run the following command:

echo 'accf_http_load="YES"' >> /boot/loader.conf

We can load the module manually by running:

# kldload accf_http

Stop and start apache22 service:

/usr/local/etc/rc.d/apache22 stop
/usr/local/etc/rc.d/apache22 start

2. Installing SNMP

To install and configure SNMP use this tutorial.

3. Installing and configuring MRTG

To install MRTG from ports, enter:

cd /usr/ports/net-mgmt/mrtg
make install clean

Configure MRTG using cfgmaker:

cfgmaker --global 'WorkDir: /usr/local/www/apache22/data/mrtg' --global 'Options[_]: growright,unknaszero' --output /usr/local/etc/mrtg/mrtg.cfg snmp_community@localhost

/usr/local/www/apache22/data/mrtg - the location you want at your webserver
/usr/local/etc/mrtg/mrtg.cfg - the location for mrtg configuration

Do not forget to change snmp community according to your snmp configuration.

Create Workdir, enter:

mkdir /usr/local/www/apache22/data/mrtg

Change current directory to mrtg directory and create index.html:

cd /usr/local/www/apache22/data/mrtg
indexmaker --title="FreeBSD Server Monitoring" --output=index.html --columns=1 /usr/local/etc/mrtg/mrtg.cfg

Now everything should be setup right try run:

/usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg

Adding the following command to /etc/crontab will update mrtg graphs every 5th minute.

*/5 * * * * root /usr/bin/env LANG=C /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log > /dev/null 2>1&

4. MRTG - mrtg.cfg configuration for CPU and Disk usage

Here is a sample configuration of mrtg.cfg used to monitor:

  • network traffic
  • cpu usage
  • disk usage
Print This Post Print This Post
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


*

No trackbacks yet.