Welcome To mkmrtg.sh

Hi! If your here it must mean your familiar with MRTG. The basis of this page is to help you with a front-end for MRTG. A quick over-view can be found to the right in the Who, What, Why, Where, How section.

Currently, mkmrtg.sh is up to Version 0.9
Remember to check out the stuff on the right.
Then click here to jump to the code. :)

------------------------------------------

Thursday, August 28, 2008

Version 0.7

#! /bin/bash

# Version 0.7

### RELEASE NOTES ###
# Yeah! mkmrtg.sh can now be run from anywhere on your system. My suggestion is to keep it in some place like "/usr/local/bin".
# Depending on how you installed MRTG, you may have "gif" images instead of "png" images. If so, change "png" to "gif". Its only in one spot below.
# If your output from MRTG is not located in "/srv/www/htdocs/mrtg" then you need to change the location variable "loc" below to the place you pointed your MRTG output.

### USAGE ###
#` Place this script in /usr/local/bin (or /usr/bin)
# chmod 700 mkmrtg.sh
# ./mkmrtg.sh
# Note: This script assumes your nodes are all in the same place.
# Example:
# /srv/www/htdocs/mrtg/
# /srv/www/htdocs/mrtg/NODE1/
# /srv/www/htdocs/mrtg/NODE2/
# /srv/www/htdocs/mrtg/NODE3/
# NOTE: Please make sure there are NO "-" (dashes) in your interface identifyer! Example: "eth0-1" is NOT good. Use "eth0_1" instead. :)
# Then point your browser to the local machine (however you setup your Apache).

### FUTURE ###
# - Notes Section via Config file
# - PHP Integration
# - Web Based Mangement via PHP
# - Clean Up Coding :)

loc="/srv/www/htdocs/mrtg"
for h in `ls $loc | fgrep -v "."`
do

html="index.html"
htlc="$loc/$h"

echo "<html><head><title>MRTG:$h</title><meta http-equiv=refresh content=60></head><body>" > $htlc/$html
echo "<h3>MRTG:$h</h3><hr width=500 align=left><table border=0>" >> $htlc/$html

for s in `ls $htlc | grep png | grep day`
do
htnm=`echo "$s" | cut -d"." -f1 | cut -d"-" -f1`
echo "<tr><td><a href=$htnm.html><img src=$s border=0></a></td><td>$htnm</td></tr>" >> $htlc/$html
done
echo "</table></body></html>" >> $htlc/$html
done

rm $loc/index.html

nvdr="$loc/nav.html"
echo "<html><head><title>Navigation</title></head><body>" > $nvdr
echo "<h4>MRTG Nodes</h4><table border=0>" >> $nvdr

for m in `find $loc | fgrep "index.html" | grep -v "~" | sort -n | cut -d"g" -f2 | cut -d"/" -f2-200`
#for m in `find $loc | fgrep "index.html" | grep -v "~" | sort -n | cut -d"." -f2-200 | cut -d"/" -f2-200`
do
indn=`echo "$m" | cut -d"/" -f1`
echo "<tr><td><a href=$m target=view><font size=2>$indn</font></a></td></tr>" >> $nvdr
done

echo "</table></body></html>" >> $nvdr

echo "<html><head><title>MRTG On `hostname`</title></head><frameset cols=200,100%><frame src=nav.html><frame src=welcome.html name=view></frameset>" > $loc/index.html

echo "<html><head><title>Welcome</title></head>" > $loc/welcome.html
echo "<h3>Welcome To MRTG!</h3>" > $loc/welcome.html
echo "<p>The 'Nodes' column on the left contains all nodes that you have selected to monitor via MRTG." >> $loc/welcome.html
echo "<p>Have fun! :D<p><font color=grey>mkmrtg.sh - Ver. 0.7" >> $loc/welcome.html
echo "<p>Script & Front-End Written By Joe McShinsky <font size=0>(Contributions Noted In Script)</font></font>" >> $loc/welcome.html

No comments: