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. :)

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

Monday, August 25, 2008

Version 0.6

#! /bin/bash

# Version 0.6

### RELEASE NOTES ###
# Currently, as far as I know, this needs to br run from /srv/www/htdocs/mrtg.
# Taking a quick look, I can see that I just need to update:
# for h in `ls | fgrep -v "."`
# to: for h in `ls $loc | fgrep -v "."`
# With $loc being set prior to this line.
# 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.

### USAGE ###
# Place this script in /srv/www/htdocs/mrtg
# 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/
# Then point your browser to the local machine (however you setup your Apache).

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

for h in `ls | fgrep -v "."`
do

html="index.html"
htlc="`pwd`/$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 index.html

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

for m in `find | 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>" > index.html

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

No comments: