Ploticus on Unix

- Visualised Performance Data out of sar: Monthly Performance -

Monthly sarThe following describes my approach to get monthly pictures like this out of sar data.
Out of sar, we produce a special file named sastat. This consists out of two lines per day: the performance averages between 10am-12am and 2pm-4pm. An example:
25-07-03       3       7       3      88
25-07-03       2       7       2      89
28-07-03       3       7       3      87
28-07-03       3       7       2      88
If someone want to get the script for producing this just let me know!
If you are interested in a pure visualizing of sar data per day, see [link] this example.
The production of the pictures based on this data file is triggered by a crontab script, owned by the web admin user (mostly httpd), running on one central server in our N/W. This server has the authorisation via .rhosts to execute remote commands as root and as web admin on all other servers. All graphs are produced on this central server so we have only one ploticus installed.
This script named looks alike (comments are in red):

# This script prepares gifs out of sastat file.
# One Input Parameter required to specify the offset to current month
# 0 -> this month
# 1 -> previous month

# version 1.0 by Andreas Schmidt, 29MAR2000

# Check for Input
if test "$1" = ""
        echo Month offset parameter needed!
if test $1 -gt 1
        echo Month offset allowed only 0 or 1!

# Definition of Directories
WORKDIR="$HOME/ploticus" must changed according to your needs
TARGETDIR="$HOME/htdocs/CTE_Unix/plots" must changed according to your needs.
                                        The Webserver should have access to this directory.

# Initial Setup
YEAR=`date "+%y"`
MONTH=`date "+%m"`
DAY=`date "+%d"`

# Final Setup depending on Input Paramenter
case $1 in
        1) case $MONTH in previous month
                01) case $YEAR in must go one year back
                        00) YEAR="99";;
                        01) YEAR="00";;
                        02) YEAR="01";;
                        03) YEAR="02";;
                        04) YEAR="03";;
                        05) YEAR="04";;
                        06) YEAR="05";;
                        07) YEAR="06";;
                        08) YEAR="07";;
                        09) YEAR="08";;
                        10) YEAR="09";;
                        *)  YEAR=`echo $YEAR|awk '{x=$1-1;print x}'`;;
                    MONTH="12"; LASTDAY="31";; must go one month back
                02) MONTH="01"; LASTDAY="31";;
                03) MONTH="02"; LASTDAY="28";; no leap year check I admit ;-)
                04) MONTH="03"; LASTDAY="31";;
                05) MONTH="04"; LASTDAY="30";;
                06) MONTH="05"; LASTDAY="31";;
                07) MONTH="06"; LASTDAY="30";;
                08) MONTH="07"; LASTDAY="31";;
                09) MONTH="08"; LASTDAY="31";;
                10) MONTH="09"; LASTDAY="30";;
                11) MONTH="10"; LASTDAY="31";;
                12) MONTH="11"; LASTDAY="30";;
           esac ;;
        0) LASTDAY="$DAY"; MONTH=`date "+%m"`; YEAR=`date "+%y"`;; actual month

# echo $YEAR/$MONTH/$DAY
# exit

# Definition of Executable

# Change Ploticus Templates for temporaer File with Date
sed s/%YEAR/$YEAR/g $WORKDIR/$EXEC.tpl | \ follow the link to see the template
sed s/%MONTH/$MONTH/g | \
sed s/%LASTDAY/$LASTDAY/g > $WORKDIR/$EXEC.temp see an example of a temp file by following the link

# Setup of Systems
AIXSYSTEMS="a probable long list of servers goes here,"

# Create Graph per System
        # Change temporaer Template for System Name
        sed s/%SYSTEM/$SYSTEM/g $WORKDIR/$EXEC.temp > $WORKDIR/$EXEC.tplf this final template gets now the system' name
        # Execute Ploticus to create the Graph
        $WORKDIR/pl -gif -o $TARGETDIR/$SYSTEM.$MONTH.gif $WORKDIR/$EXEC.tplf

The basic template sar_plot_month.tpl contains placeholders for the time parameters Month and Year, and the System's name. All the rest is "pure" ploticus:
// Read data from file
#proc getdata
  command: remsh %SYSTEM -l root grep -e -%MONTH-%YEAR /var/adm/sa/sastat
  get the sastat data on the wanted server for the selected Month.

#proc areadef
  title: CPU Utilization Average % per day
  rectangle: 1 1 8 5
  yrange: 0 100
  xrange: 0 50

#proc xaxis
  stubvert: yes
  stubs: datafields=1

//  define a Y axis using proc yaxis
#proc yaxis
  label: CPU Utilization in %
  stubs: inc 20
  minortics: yes
  minorticinc: 5

//  Do the green grid lines..
#proc yaxis
  ticincrement: 10
  grid: color=green
  stubs: none
  tics: none

#proc bars
  lenfield: 2
  color: red
  barwidth: 0.07
  legendlabel: usr%
  #saveas B

#proc bars
  #clone: B
  lenfield: 3
  color: blue
  legendlabel: sys%
  stackfields: 2

#proc bars
  #clone B
  lenfield: 4
  color: yellow
  legendlabel: wio%
  stackfields: 2 3

#proc annotate
  location: 2 6.2
  box: color=red width=1.0
  backcolor: gray(0.8)
  text: CPU Utilization consists out of
        User-, System Processes- and
        Wait for I/O Activity-CPU Util%
        and represents the usage in % of the
        total processing capacity available.

#proc annotate
  location: 5 6
  box: color=black width=1.0
  backcolor: gray(0.8)
  textdetails: size=18
  text: %SYSTEM
        20%YEAR %MONTH

#proc legend
  location: min+2 max-0.5
  format: singleline

The intermediate temporar file sar_plot_month.temp looks very similiar - with two changes:
// Read data from file
#proc getdata
  command: remsh %SYSTEM -l root grep -e -07-03 /var/adm/sa/sastat
#proc annotate
  location: 5 6
  box: color=black width=1.0
  backcolor: gray(0.8)
  textdetails: size=18
  text: %SYSTEM
        2003 07

The last step producing the sar_plot_month.tplf replaces the system name. This is the final input file for ploticus, invoked by
last changed: 30.07.2003
© 2003 Andreas Schmidt