#!/bin/sh
# This script creates html code and a gif file generated by Ploticus
# to display a report graph for a dedicated account.
# Expects one Input Parameter.
# version 0.5 by Andreas Schmidt, 29MAY2000
if test $# -ne 1
then
echo "ERROR, graph_report (1): No account name specified on command line."
echo " "
echo "Usage: graph_report Account_Name"
echo " "
echo "(c) 2000 Andreas Schmidt"
echo "http://www.hillschmidt.de/ploticus"
exit
fi
# Setting Variables
SYSTEM=`uname -n` # System's Name
ACCOUNT=$1 # Input: Account's Name
PLOTX=/tmp/report_PLOTxeq # Ploticus Final XEQ file
REPACT=/tmp/report_$ACCOUNT # Original REPORT output file
REPGRP=/tmp/groups_$ACCOUNT # Data file for Ploticus
STOREDIR=/APACHE/PUB/htdocs # Directory where web files will be stored
GIFNAME=report_$ACCOUNT.gif # Name of .gif file
HTMNAME=report_$ACCOUNT.htm # Name of HTML source file
STOREGIF=$STOREDIR/$GIFNAME # Complete .gif file's name
STOREHTM=$STOREDIR/$HTMNAME # Complete HTML file's name
let SUMREM=0 # Sum of Groups' Sectors not displayed
# One of the following lines needs to become activated, depending on Account's Size:
# let THRESHOLD=2048; MB="0.5" # Minimum # of Sectors to be displayed (500 KB)
let THRESHOLD=4096; MB=1 # Minimum # of Sectors to be displayed (1 MB)
# let THRESHOLD=8192; MB=2 # Minimum # of Sectors to be displayed (2 MB)
# let THRESHOLD=20480; MB=5 # Minimum # of Sectors to be displayed (5 MB)
# let THRESHOLD=40960; MB=10 # Minimum # of Sectors to be displayed (10 MB)
# let THRESHOLD=204800; MB=50 # Minimum # of Sectors to be displayed (50 MB)
# let THRESHOLD=409600; MB=100 # Minimum # of Sectors to be displayed (100 MB)
# let THRESHOLD=4194304; MB=1024 # Minimum # of Sectors to be displayed (1 GB)
# Clearing Files
rm $PLOTX
rm $REPACT
rm $REPGRP
rm $STOREGIF
rm $STOREHTM
# Web Page Header
# echo "Content-type: text/html\n"
echo "<HTML>" > $STOREHTM
echo "<HEAD><TITLE>Graphical Report Command</TITLE></HEAD>" >> $STOREHTM
echo "<BODY>" >> $STOREHTM
echo "<CENTER>" >> $STOREHTM
echo "<H2>Graphical REPORT Command for Account $ACCOUNT on Server $SYSTEM</H2>" >> $STOREHTM
echo "<H3>Display Threshold: Min. $THRESHOLD Sectors ($MB MB) per Group</H3>" >> $STOREHTM
echo "<HR>" >> $STOREHTM
echo "<IMG src=$GIFNAME align=left>" >> $STOREHTM
echo "<H3>Groups not displayed:</H3>" >> $STOREHTM
echo "<TABLE border=2>" >> $STOREHTM
echo "<TR><TD><B>GroupName</B></TD><TD><B>Sectors</B></TD></TR>" >> $STOREHTM
# MPE command and reducing to the needed information
callci "REPORT @.$ACCOUNT"|grep -v "ACCOUNT"|grep -v "/GROUP"|grep -v "$ACCOUNT"|sed -e s/*\\///g -e s/\\///g > $REPACT
while read GROUP SECTORS SHIT
do
if test $SECTORS -gt $THRESHOLD
then
echo "$GROUP:@PCT% $SECTORS" >> $REPGRP
else
echo "<TR><TD>$GROUP</TD><TD>$SECTORS</TD></TR>" >> $STOREHTM
let SUMREM=$SUMREM+$SECTORS
fi
done < $REPACT
echo "<TR><TD align=right><B>Remaining Sum</B></TD><TD align=right><B>$SUMREM</B></TD></TR>" >> $STOREHTM
echo "</TABLE>" >> $STOREHTM
echo "Remaining:@PCT% $SUMREM" >> $REPGRP
# Creating Ploticus XEQ
echo "#proc page" > $PLOTX
echo "backgroundcolor: yellow" >> $PLOTX
echo "#proc getdata" >> $PLOTX
echo "command: cat $REPGRP" >> $PLOTX
echo "#proc pie" >> $PLOTX
echo "firstslice: 0" >> $PLOTX
echo "datafield: 2" >> $PLOTX
echo "labelfield: 1" >> $PLOTX
echo "labelmode: line+label" >> $PLOTX
echo "center: 4 4" >> $PLOTX
echo "radius: 2" >> $PLOTX
echo "colors: red green blue orange red green blue orange red green blue orange red green blue orange red green blue orange" >> $PLOTX
echo "labelfarout: 1.3" >> $PLOTX
echo "textdetails: size=10" >> $PLOTX
echo "pctformat: %.0f" >> $PLOTX
echo "#proc annotate" >> $PLOTX
echo "location: 1 7" >> $PLOTX
echo "box: color=red width=1.0" >> $PLOTX
echo "backcolor: gray(0.8)" >> $PLOTX
echo "text: $SYSTEM\nAccount: $ACCOUNT" >> $PLOTX
# Running Ploticus
/usr/local/ploticus/bin/pl $PLOTX -gif -o $STOREGIF
# Output to Browser
echo "<BR clear=all><HR>" >> $STOREHTM
echo "© Andreas Schmidt, May 2000</BODY></HTML>" >> $STOREHTM
chmod 644 $STOREGIF
chmod 644 $STOREHTM
|