## version 4 2012-01-08 

PACKAGE_NAME MRTG - Multi-Router Traffic Grapher
PACKAGE_DESCR Graphs network traffic (and other SNMP variables).<br>
PACKAGE_DESCR Requires perl (perl-5.10.0-i486-1.tgz) to be installed. Piggybacks on emhttp to show the charts (which are pngs/html).<br>  
PACKAGE_DESCR On <font color='blue'>unRAID 4.6</font>, MRTG charts will be available at http://tower/log/mrtg/index.html<br>
PACKAGE_DESCR On <font color='blue'>unRAID 5.0 beta 14</font>, MRTG charts will be available at http://tower/mrtg/index.html<br>
PACKAGE_DESCR <b>the index.html part of the url is significant, without that the page will not load!</b><p>
PACKAGE_DESCR MRTG log files don't grow, so no need to worry about filling up the RAMdisk or wherever you're storing it.
PACKAGE_DESCR <p>See the MRTG website <a href="http://oss.oetiker.ch/mrtg/">http://oss.oetiker.ch/mrtg/</a> for details and docs.
PACKAGE_DESCR <p>This package also intstalls net-snmp, gd, and their dependencies.  This package only sets up 
PACKAGE_DESCR the basic ethernet interface chart (or charts in the case of multiple ethernet interfaces)
PACKAGE_DESCR <p>Sample Charts <a href='http://ruinedkingdoms.com/unRAID/mrtg_sample_index.png'>here</a>. Sample advanced mrtg.cfg file 
PACKAGE_DESCR <a href='http://ruinedkingdoms.com/unRAID/mrtg.cfg'>here</a>.

PACKAGE_URL http://ruinedkingdoms.com/unRAID/mrtg-2.17.3-i486-0.tgz
## Source code (for GPL) http://ruinedkingdoms.com/unRAID/mrtg-2.17.3.tar.gz
PACKAGE_FILE mrtg-2.17.3-i486-0.tgz
PACKAGE_MD5 2d0c9d84f7edbd0f6d6c6ddf2536a1c7
PACKAGE_INSTALLED /usr/bin/mrtg
PACKAGE_DEPENDENCIES perl-5.10.0-i486-1.tgz

## net-snmp is required for mrtg
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/n/net-snmp-5.5-i486-2.txz
PACKAGE_EXTRA_FILE net-snmp-5.5-i486-2.txz
PACKAGE_EXTRA_MD5 40ec4f6e3c59f50498312ef6f82ab161

## gd is required for mrtg
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/l/gd-2.0.35-i486-4.txz
PACKAGE_EXTRA_FILE gd-2.0.35-i486-4.txz
PACKAGE_EXTRA_MD5 f651dfb4ec97c3091ad273b840f6308b

## fontconfig is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/fontconfig-2.8.0-i486-1.txz
PACKAGE_EXTRA_FILE fontconfig-2.8.0-i486-1.txz
PACKAGE_EXTRA_MD5 50e2e06ad58d40f54ff0df0261922404

## freetype is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/l/freetype-2.3.12-i486-1.txz
PACKAGE_EXTRA_FILE freetype-2.3.12-i486-1.txz
PACKAGE_EXTRA_MD5 7ec1bcbb3db434392b5ef2cf92204222

## libjpeg is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/l/libjpeg-v8a-i486-1.txz
PACKAGE_EXTRA_FILE libjpeg-v8a-i486-1.txz
PACKAGE_EXTRA_MD5 eded23e2b33edb951314301cfcf16bbb

## libnl is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/l/libnl-1.1-i486-1.txz
PACKAGE_EXTRA_FILE libnl-1.1-i486-1.txz
PACKAGE_EXTRA_MD5 03112928d8979fb28293e93d5346d9bd

## libpng is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/l/libpng-1.4.2-i486-1.txz
PACKAGE_EXTRA_FILE libpng-1.4.2-i486-1.txz
PACKAGE_EXTRA_MD5 2eb8ad5829b2510dceb32c70dd119a3e

## libX11 is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/libX11-1.3.3-i486-1.txz
PACKAGE_EXTRA_FILE libX11-1.3.3-i486-1.txz
PACKAGE_EXTRA_MD5 de7dcdf973abe2d150e2d0d99e6ccc50

## libXau is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/libXau-1.0.5-i486-1.txz
PACKAGE_EXTRA_FILE libXau-1.0.5-i486-1.txz
PACKAGE_EXTRA_MD5 fceb0342c5c899b3df5433a09be90cb6

## libxcb is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/libxcb-1.6-i486-1.txz
PACKAGE_EXTRA_FILE libxcb-1.6-i486-1.txz
PACKAGE_EXTRA_MD5 99db4bd10e99ee5b4d335f45df8548df

## libXdmcp is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/libXdmcp-1.0.3-i486-1.txz
PACKAGE_EXTRA_FILE libXdmcp-1.0.3-i486-1.txz
PACKAGE_EXTRA_MD5 1aa97b30e7114f86ef3443e9c6d24665

## libXpm is required for gd
PACKAGE_EXTRA_URL http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/x/libXpm-3.5.8-i486-1.txz
PACKAGE_EXTRA_FILE libXpm-3.5.8-i486-1.txz
PACKAGE_EXTRA_MD5 5bfdaf03edbf189eaf3c029178530859

## user variables
PACKAGE_VARIABLE SNMP RO Community||v_rocommunity=public||This is the community name (like a userid) to grant read-only access via SNMP.
PACKAGE_VARIABLE SNMP Location||v_location=Here||This is where the device is located and is displayed by SNMP.
PACKAGE_VARIABLE SNMP Contact||v_contact=me@example.com||This is who maintains the device and is displayed by SNMP.
PACKAGE_VARIABLE MRTG Interface||v_ip=localhost||This is the IP Address of the Interface you want to monitor.  Default is localhost (127.0.0.1).
PACKAGE_VARIABLE MRTG Chart Options||v_chart=growright,bits||This is the base MRTG chart settings. Default is show scale in bits and have newer data on right.
PACKAGE_VARIABLE MRTG Data Location||v_data=/tmp/mrtg||This is the directory where MRTG will store its data. Default is in /tmp, which means the data will reset every reboot.

## install perl
PACKAGE_INSTALLATION if [[ ! -f /usr/bin/perl && ! -f "${PACKAGE_DIRECTORY}"/perl-5.10.0-i486-1.tgz ]]; then
PACKAGE_INSTALLATION    echo "Required dependency, perl-5.10.0-i486-1.tgz, has not been installed. Please install it before installing MRTG."
PACKAGE_INSTALLATION    echo "You can install the package <a href=\"${MyHost}:${MyPort}/pkg_manager?select-perl-5.10.0-i486-1.tgz=Select+perl-5.10.0-i486-1.tgz\">Here</a>" 
PACKAGE_INSTALLATION    exit
PACKAGE_INSTALLATION else
PACKAGE_INSTALLATION     test ! -f /usr/bin/perl && installpkg "${PACKAGE_DIRECTORY}"/perl-5.10.0-i486-1.tgz
PACKAGE_INSTALLATION fi

## stop snmpd if started and install packages
PACKAGE_INSTALLATION killall snmpd
PACKAGE_INSTALLATION installpkg net-snmp-5.5-i486-2.txz
PACKAGE_INSTALLATION installpkg freetype-2.3.12-i486-1.txz
PACKAGE_INSTALLATION installpkg fontconfig-2.8.0-i486-1.txz
PACKAGE_INSTALLATION installpkg gd-2.0.35-i486-4.txz
PACKAGE_INSTALLATION installpkg libjpeg-v8a-i486-1.txz
PACKAGE_INSTALLATION installpkg libnl-1.1-i486-1.txz
PACKAGE_INSTALLATION installpkg libpng-1.4.2-i486-1.txz
PACKAGE_INSTALLATION installpkg libX11-1.3.3-i486-1.txz
PACKAGE_INSTALLATION installpkg libXau-1.0.5-i486-1.txz
PACKAGE_INSTALLATION installpkg libxcb-1.6-i486-1.txz
PACKAGE_INSTALLATION installpkg libXdmcp-1.0.3-i486-1.txz
PACKAGE_INSTALLATION installpkg libXpm-3.5.8-i486-1.txz
PACKAGE_INSTALLATION installpkg mrtg-2.17.3-i486-0.tgz

## create base snmpd.conf file and start snmpd
PACKAGE_INSTALLATION if [[ ! -f /boot/config/snmpd.conf ]]; then
PACKAGE_INSTALLATION   echo "rocommunity $v_rocommunity" > /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "syslocation $v_location" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "syscontact $v_contact" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk1" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk2" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk3" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk4" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk5" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk6" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk7" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk8" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk9" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk10" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk11" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk12" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk13" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk14" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk15" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk16" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk17" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk18" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk19" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/disk20" >> /boot/config/snmpd.conf
PACKAGE_INSTALLATION   echo "disk /mnt/cache" >> /boot/config/snmpd.conf


PACKAGE_INSTALLATION fi
PACKAGE_INSTALLATION sed -e 's/\/etc\/snmp\/snmpd.conf/\/boot\/config\/snmpd.conf/g' /etc/rc.d/rc.snmpd > /etc/rc.d/rc.snmpd.new
PACKAGE_INSTALLATION mv /etc/rc.d/rc.snmpd.new /etc/rc.d/rc.snmpd
PACKAGE_INSTALLATION rm /etc/snmp/snmpd.conf
PACKAGE_INSTALLATION chmod +x /etc/rc.d/rc.snmpd
PACKAGE_INSTALLATION /etc/rc.d/rc.snmpd start

## create mrtg.cfg on USB drive, if doesn't exist
PACKAGE_INSTALLATION [ ! -f /boot/config/mrtg.cfg ] && /usr/bin/cfgmaker --global "WorkDir: $v_data" --global "Options[_]: $v_chart" $v_rocommunity@$v_ip  > /boot/config/mrtg.cfg

## create mrtg output directory, if doesn't exist
PACKAGE_INSTALLATION [ ! -d $v_data ] && mkdir $v_data

## symlink mrtg output directory into emhttp path for viewing
PACKAGE_INSTALLATION [[ -d /usr/local/emhttp && ! -h /usr/local/emhttp/mrtg ]] && ln -s $v_data /usr/local/emhttp/mrtg
PACKAGE_INSTALLATION [[ ! -d /usr/local/emhttp && ! -h /var/log/mrtg ]] && ln -s $v_data /var/log/mrtg

## run mrtg twice to create log files and images (to save these from being cron errors later)
PACKAGE_INSTALLATION echo "** 3 Ratup WARNINGS are normal following the inital startup of MRTG **"
PACKAGE_INSTALLATION env LANG=C /usr/bin/mrtg --lock-file /tmp/mrtg_lockfile /boot/config/mrtg.cfg
PACKAGE_INSTALLATION env LANG=C /usr/bin/mrtg --lock-file /tmp/mrtg_lockfile /boot/config/mrtg.cfg 

## add line to crontab running mrtg every 5 minutes
PACKAGE_INSTALLATION (crontab -l | grep -v mrtg.cfg; echo "*/5 * * * * env LANG=C /usr/bin/mrtg --lock-file /tmp/mrtg_lockfile /boot/config/mrtg.cfg") | crontab -

## create index.html for mrtg area
PACKAGE_INSTALLATION /usr/bin/indexmaker --output=$v_data/index.html /boot/config/mrtg.cfg

## test to see if package installed
PACKAGE_VERSION_TEST env LANG=C /usr/bin/mrtg | grep "Multi Router" | awk '{ print $1 }' 
PACKAGE_VERSION_STRING mrtg-2.17.3
PACKAGE_MEMORY_USAGE Medium (7.7MB Compressed)
