Tested on:
NAS4Free 9.2.0.1 - Shigawire (rev 943 & 972)
Platform x64-Embedded on 1GB USB Flash Stick on HP Microserver N40L (AMD64)
Continuing on from my previous guide, [HOWTO] Install MRTG SNMP Monitoring Inside Jail, this guide will focus on using MRTG with RRDTool. For this, we will be using the mrtg-rrd.cgi file included in this guide which will be accessible through Apache. This mrtg-rrd.cgi is one I have modified slightly to use the default MRTG configuration file and to provide nicer graphs. The original version can be found at the MRTG-RRD homepage HERE, please click HERE for example graphs using the original version.
This guide assumes you have a system with a jail called 'mrtg' with an IP address of 192.168.1.251, fully working Internet access, SSH and a file editor (Nano). This jail will also have a working installation of MRTG and Apache 2.x as per my previous guide. Please note that this will be using Apache 2.4 which has a few config differences in comparison to Apache 2.2.
Before I begin, the sources I give credit to are the following:
Tobi Oetiker's MRTG Homepage
Jan "Yenya" Kasprzak's MRTG-RRD Homepage
First, we need to enter the jail:
Code: Select all
nas4free: ~ # jexec 1 csh
root@mrtg:/ #Code: Select all
portsnap fetch updateCode: Select all
cd /usr/ports/databases/rrdtool/
make install cleanCode: Select all
pkg install databases/rrdtoolWe now need to edit the MRTG config to tell it to use RRDTool:
Code: Select all
nano /usr/local/etc/mrtg/mrtg.cfgCode: Select all
LogFormat: rrdtool
WorkDir: /usr/local/www/apache24/data/mrtg
PathAdd: /usr/local/bin/
LibAdd: /usr/local/bin/
IconDir: /mrtg
RunAsDaemon: Yes
Code: Select all
env LANG=C /usr/local/bin/mrtg --logging /var/log/mrtg.log --user mrtg --group mrtg --daemon /usr/local/etc/mrtg/mrtg.cfgCode: Select all
2014-09-01 21:48:16 -- Started mrtg with config '/usr/local/etc/mrtg/mrtg.cfg'
Daemonizing MRTG ...Code: Select all
ls -ltr /usr/local/www/apache24/data/mrtg/*.rrdCode: Select all
chown www:www *.png; chown www:www *.html; chown mrtg:mrtg *.rrdCode: Select all
nano /usr/local/etc/apache24/httpd.confCode: Select all
#LoadModule cgi_module libexec/apache24/mod_cgi.soCode: Select all
LoadModule cgi_module libexec/apache24/mod_cgi.soCode: Select all
ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"Code: Select all
<Directory "/usr/local/www/apache24/cgi-bin">
AllowOverride None
Options +ExecCGI
Require all granted
</Directory>Code: Select all
<Directory "/usr/local/www/apache22/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>Code: Select all
tar -zxvf mrtg-rrd.tgz
mv mrtg-rrd.cgi /usr/local/www/apache24/cgi-bin
chown www:www mrtg-rrd.cgi; chmod 755 mrtg-rrd.cgiThe final step is to restart Apache so it picks up the config changes and uses mrtg-rrd.cgi:
Code: Select all
/usr/local/etc/rc.d/apache24 restartIf Apache displays an error such as 403 Forbidden, check the Apache error logs for clues, this may be due to permissions:
Code: Select all
less /var/log/httpd-error.logCode: Select all
ls -ltr /usr/local/www/apache24/data/mrtg/*.imgCode: Select all
ls -ltr /usr/local/www/apache24/data/mrtg/*.rrdI hope some of you find this guide useful, any corrections or recommendations are welcome.
