Ploticus/iX

- DISCFREE 3 -


[SysVol]A shell script creates a graphical DISCFREE per Volume Set and Disk like

The complete HTML code will result in [link] this small example  .
Another big example can be seen [link]  here  .

The content of this script is

#!/bin/sh

# This script creates html code to display discfree graphs generated by Ploticus.
# version 0.7 by Andreas Schmidt, 26MAY2000

# Setting Variables
MPEO=/tmp/DISCFREE                              # Discfree Output file
MPEOT=/tmp/DISCFREE2                            # Discfree Intermed. Output file
PLOTT=/tmp/PLOTtemplate                         # Ploticus XEQ Template file
PLOTX=/tmp/PLOTxeq                              # Ploticus Final XEQ file
LDEVA=/tmp/LDEVall                              # all info per device in one line file
STORE=/APACHE/PUB/htdocs                        # Location where .gifs will be stored dir
HTML=$STORE/graph_discfree.htm                  # full Name of final Web Page file

# Clearing Files
rm $MPEO
rm $MPEOT
rm $PLOTT
rm $PLOTX
rm $LDEVA
rm $HTML

# Initializing Values
let LDEV=0
let SIZE=0
let CONF=0
let USED=0
let FREE=0
let REST=0
let DPL=2                        #Disc gifs per line in Web Table

# Web Page Header
# echo "Content-type: text/html\n"
# The previous line is needed when the script should run as cgi out of a Browser.
# This is not recommended. But if wanted the redirection to $HTML must eliminated as well.
echo "<HTML>"                                                                   >  $HTML
echo "<HEAD><TITLE>Graphical Discfree</TITLE></HEAD>"     >> $HTML
echo "<BODY>"                                                               >> $HTML
echo "<CENTER>"                                                             >> $HTML
echo "<H2>Graphical Discfree Report on each Volume Set and Disc</H2>" >> $HTML
echo "<HR>"                                                                 >> $HTML

# Calling MPE
callci "DISCFREE 3" > $MPEOT

# Adopting original DISCFREE Output
sed -e s/"("//g -e s/")"//g $MPEOT > $MPEO

# Creating Ploticus Template
echo "#proc page"                                   >  $PLOTT
echo "backgroundcolor: %COLO"                   >> $PLOTT
echo "#proc getdata"                            >> $PLOTT
echo "data:"                                    >> $PLOTT
echo "%USED"                                    >> $PLOTT
echo "%FREE"                                    >> $PLOTT
echo "%REST"                                    >> $PLOTT
echo "#proc pie"                                >> $PLOTT
echo "firstslice: 0"                            >> $PLOTT
echo "datafield: 1"                             >> $PLOTT
echo "labelmode: line+label"                    >> $PLOTT
echo "center: 1.5 1.5"                          >> $PLOTT
echo "radius: 0.5"                              >> $PLOTT
echo "colors: red green black"                  >> $PLOTT
echo "labelfarout: 1.1"                         >> $PLOTT
echo "textdetails: size=10"                     >> $PLOTT
echo "pctformat: %.0f"                          >> $PLOTT
echo "labels: Used (@@PCT%)"                    >> $PLOTT
echo "Free (@@PCT%)"                            >> $PLOTT
echo "Rest (@@PCT%)"                            >> $PLOTT
echo "#proc annotate"                           >> $PLOTT
echo "location: 1.6 2.5"                        >> $PLOTT
echo "box: color=red width=1.0"                 >> $PLOTT
echo "backcolor: gray(0.8)"                     >> $PLOTT
echo "text: %TEXT"                              >> $PLOTT

# Reading DISCFREE modifed output into new format
while read F1 F2 F3 F4 F5 F6 F7 F8 F9 F10
do
        if test "$F1" = "LDEV"
        then
                LDEV=$F3
                VOLS=$F5
        fi
        if test "$F1" = "Device"
        then
                SIZE=$F3
        fi
        if test "$F1" = "Permanent"
        then
                CONF=$F3
                USED=$F6
                FREE=$F9
        fi
        if test $LDEV -gt 0
        then
                if test $CONF -gt 0
                then
                        echo $LDEV $VOLS $SIZE $CONF $USED $FREE >> $LDEVA
                        # Calculating Values per Disk and creating the .gif
                        let REST=$SIZE-$CONF+1                # to get at least 1 for better calculation
                        TEXT="LDEV $LDEV ($VOLS)"
                        sed -e s/%USED/"$USED"/ -e s/%FREE/"$FREE"/ -e s/%REST/"$REST"/ -e s/%TEXT/"$TEXT"/ -e s/%COLO/tan1/ $PLOTT > $PLOTX
                        /usr/local/ploticus/bin/pl $PLOTX -gif -o $STORE/ldev$LDEV.gif
                        let LDEV=0
                        let SIZE=0
                        let CONF=0
                        let USED=0
                        let FREE=0
                        let REST=0
                fi
        fi
done < /tmp/DISCFREE

# Creating the Volume Set Graph
for VOLSET in $(cut -f1 -d: $LDEVA|cut -f2 -d" "|sort -u)
do
        let SIZE=0
        let CONF=0
        let USED=0
        let FREE=0
        let REST=0
        grep $VOLSET $LDEVA > /tmp/$VOLSET
        # Reading all discs per Volume Set
        while read F1 F2 F3 F4 F5 F6
        do
                let SIZE=$SIZE+$F3
                let CONF=$CONF+$F4
                let USED=$USED+$F5
                let FREE=$FREE+$F6
        done < /tmp/$VOLSET
        # Calculating and Ploticus call
        let REST=$SIZE-$CONF+1                                # to get at least 1 for better calculation
        TEXT="$VOLSET"
        sed -e s/%USED/"$USED"/ -e s/%FREE/"$FREE"/ -e s/%REST/"$REST"/ -e s/%TEXT/"$TEXT"/ -e s/%COLO/skyblue/ $PLOTT > $PLOTX
        /usr/local/ploticus/bin/pl $PLOTX -gif -o $STORE/$VOLSET.gif
        # Output to Browser
        echo "<H4>$VOLSET</H4>"                                       >> $HTML
        echo "<TABLE border=2>"                                             >> $HTML
        echo "<TR><TH colspan=$DPL><IMG src=$VOLSET.gif></TH></TR>"        >> $HTML
        echo "<TR>"                                                         >> $HTML
        # Output of all LDEV gifs belonging to VolSet
        let i=0
        for NUM in $(cut -f1 -d" " /tmp/$VOLSET|sort -u)
        do
                echo "<TD><IMG src=ldev$NUM.gif></TD>"          >> $HTML
                let i=$i+1
                if test $i -eq $DPL
                then
                        let i=0
                        echo "</TR><TR>"                              >> $HTML
                fi
        done
        echo "</TR></TABLE><HR>"                                >> $HTML
done
echo "© Andreas Schmidt, May 2000</BODY></HTML>"                 >> $HTML



Remarks:
  1. The whole process to create the needed gifs (and the HTML code) is CPU intensive.
  2. Disc Mirroring is not reflected - that's the reason I show only the percentages.
  3. It is possible to run the script as cgi-bin under a Web Server like Apache/iX but not recommended.
    But it is recommended to run this script from time to time as Server User of the Web Server (like SERVER.APACHE) to get the right security for the files.
  4. You may split this script into different parts, of course.
  5. It's just an idea to create all gifs in one run but a different HTML code. You may want to use the gif of the Volume Set as linking image to another HTML page just displaying the gifs of all LDEVs belonging to this volume set.
Example: I stored the script named graph_discfree as SERVER.APACHE in /APACHE/PUB/cgi-bin and run it out of the shell:
/APACHE/PUB/cgi-bin/ > graph_discfree
/APACHE/PUB/cgi-bin/ >
Now I invoke my Browser looking to the URL http://{my_HP3000_Apache_Server}/graph_discfree.htm and I will see the whole Discspace Picture as given in the links of [link] a small server (less disks)  or [link] a large server (a lot of mirrored disks)  .


last changed: 30.04.2003
© 2003 Andreas Schmidt