|
Written by Administrator
|
|
Thursday, 23 April 2009 05:41 |
|
I ran the following script on my Centos 5.2 VM and all I had to do after was add the crontab entry manually and restart mrtg. I got pretty pictures like these:
NOTE: You must first install gcc and gd-devel or the script won't work. If you already have anything under /var/www/html/mrtg delete all of it. Make sure httpd is installed and started. 




#!/bin/bash
echo "MRTG Installer 1.0 ---------------------" echo "By: Matt Savona (www.serveio.com)" echo -e "----------------------------------------\n\n"
USER=`whoami`
if [ "$USER" != "root" ]; then echo "You must be logged in as root to use this installer!" exit 0; fi
echo "Checking for previous MRTG installation..."
if [ -d /var/www/html/mrtg ]; then FILECOUNT=`ls /var/www/html/mrtg | wc -l` if [ "$FILECOUNT" -ge "1" ]; then echo "There appears to be files in /var/www/html/mrtg already! Exiting..." exit 0; else echo "The directory /var/www/html/mrtg exists, but there are no files. This is okay..." fi else echo "The directory /var/www/html/mrtg does not exist. I will create it..." mkdir /var/www/html/mrtg fi
echo "Creating necessary directories and preparing for installation..."
mkdir /var/www/html/mrtg/core chmod 700 /var/www/html/mrtg/core
WD=`pwd` cd /usr/local/src rm -rf mrtg*
echo "Preparations complete..."
echo "Downloading the most recent MRTG and installing it..." #wget http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg.tar.gz wget http://oss.oetiker.ch/mrtg/pub/mrtg.tar.gz tar zfx mrtg.tar.gz cd mrtg* ./configure --with-gd=/usr/local/lib make make install
echo "MRTG has been installed..." echo "Updating MRTG config and template..."
wget http://www.serveio.com/da/mrtgcfg.tar.gz tar zfx mrtgcfg.tar.gz chmod +x system mv -f system /var/www/html/mrtg/core mv -f mrtg.cfg /var/www/html/mrtg/core
echo "Update complete!"
echo "Adding MRTG to /etc/crontab..." echo "*/5 * * * * root /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg" >> /etc/crontab echo "" >> /etc/crontab
echo "Executing MRTG for the first time (you may see some warnings)..." /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg echo "If you see warnings above, it is generally safe to ignore."
echo "Cleaning up installation..." rm -rf mrtg* cd $WD echo "Installation of MRTG complete!"
|
|
Last Updated on Sunday, 25 October 2009 06:35 |