Mrtg + Nginx On Debian Squeeze with 1 minute interval

Quick note really:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# install nginx, mrtg, and fcgiwrap to wrap mrtg cgi since nginx doesn't support cgi directly
sudo apt-get install nginx mrtg mrtg-rrd rrdtool librrds-perl fcgiwrap

# prepare directories
sudo mkdir -p /var/www/mrtg /var/log/mrtg
sudo chown -R www-data.  /var/www/mrtg /var/log/mrtg
sudo -u www-data cp /usr/share/mrtg/* /var/www/mrtg# prepare the cron job, 1 minute interval is used
sudo sh -c 'echo "* * * * * www-data if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi" > /etc/cron.d/mrtg'

# Generate config
sudo sh -c "cfgmaker --global 'Interval: 1' --global 'LogFormat: rrdtool' --global 'IconDir: /mrtg' 10.0.12.254 /etc/mrtg.cfg"
sudo rm -rf /var/lock/mrtg/

### edit /etc/nginx/sites-enabled/default and include /usr/share/doc/fcgiwrap/examples/nginx.conf
sudo service nginx reload

Then visit http://localhost/cgi-bin/mrtg-rrd.cgi/ for the graph