14.16. Creating Multiple MRTG Index Pages

Your MRTG server is humming along happily, but you have a problem—your index page is growing out of control. How do you bring some organization to the MRTG index?

You might create separate index pages. You may choose to organize by hosts, service, or any way you want. In this recipe, we'll create a separate MRTG index page for the Linux server Uberpc, following these steps:

First, create a mrtg-uberpc.cfg file, and populate it with your chosen monitors. We're past the training wheels stage, so we won't bother with cfgmaker, but we will create the file from scratch. Be sure to specify the correct workdir:

	workdir: /var/www/mrtg/uberpc

Then, create the /var/www/mrtg/uberpc directory and the logfile directory:

	# mkdir /var/www/mrtg/uberpc
	# mkdir /var/log/mrtg/mrtg-uberpc.log

Next, run the two graph and index page creation commands:

	# env LANG=C mrtg /etc/mrtg-uberpc.cfg
	# indexmaker --output=/var/www/mrtg/uberpc/index.html /etc/mrtg-uberpc.cfg

Run env LANG=C mrtg/etc/mrtg-uberpc.cfg three times, until it stops emitting error messages.

Finally, add a new cron job for the new configuration in /etc/cron.d/mrtg. This example copies the default Debian cron configuration for MRTG:

	### xena
	*/5 *   * * *   root    if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] && [ -
	r /etc/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.
	log 2>&1; fi else mkdir /var/lock/mrtg; fi
	
	#### uberpc
	*/5 *   * * *   root    if [ -d /var/lock/mrtg ]; then if [ -x /usr/bin/mrtg ] && [ -
	r /etc/mrtg-uberpc.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg-uberpc.cfg >> /var/
	log/mrtg/mrtg-uberpc.log 2>&1; fi else mkdir /var/lock/mrtg; fi

Finally, point your web browser to localhost (http://localhost/mrtg/uberpc/), and enjoy your new MRTG pages.

Depending on how powerful your MRTG server is, running all those cron jobs will eventually bog it down. Running MRTG as a daemon is more efficient; see Recipe 14.17 for more information.