#!/bin/sh
# This script prints tables out of AIX System Activity Reporting (sar).
# As option, the /var/adm/sa/xxstat files can be printed additionally.
# version 0.1 by Andreas Schmidt, 29MAY1998
echo "Content-type: text/html\n"
#Directory for Ploticus files
PLOT=/usr/local/httpd/ploticus must be adopted for your needs
OUT=/usr/local/httpd/htdocs/plots should be accessible by the web daemon
#QUERY_STRING contains:system=x&special=rep&start=#&end=#&day=#&i=#&opt=n
SYSTEM_special=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[2]}'`
SYSTEM=`echo $SYSTEM_special|awk '{split($1,arr,"&");print arr[1]}'`
SPECIAL_start=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[3]}'`
SPECIAL=`echo $SPECIAL_start|awk '{split($1,arr,"&");print arr[1]}'`
START_end=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[4]}'`
START=`echo $START_end|awk '{split($1,arr,"&");print arr[1]}'`
END_day=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[5]}'`
END=`echo $END_day|awk '{split($1,arr,"&");print arr[1]}'`
DAY_i=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[6]}'`
DAY=`echo $DAY_i|awk '{split($1,arr,"&");print arr[1]}'`
I_opt=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[7]}'`
I=`echo $I_opt|awk '{split($1,arr,"&");print arr[1]}'`
OPT=`echo $QUERY_STRING|awk '{split($1,arr,"=");print arr[8]}'|cut -c1`
# echo "$SYSTEM $SPECIAL $START $END $DAY $I $OPT"
if [ $SYSTEM = "all" ]
then
SYSTEM_QUERY="a list of your servers, e.g. alpha.dot.com beta.dot.com gamma.dot.com"
else
SYSTEM_QUERY="$SYSTEM"
fi
echo "<html><head><meta http-equiv=expires content=0></head>"
for SYS in $SYSTEM_QUERY
do
if [ $SPECIAL != "none" ]
then
echo "<CENTER><H2>Latest <I>/var/adm/sa/$SPECIAL</I> file content on <I>$SYS</I></H2></CENTER><PRE>"
remsh $SYS -l root cat /var/adm/sa/$SPECIAL
else
case $OPT in only the system wide statistics produces graphs!
u) sed s/%SYSTEM/$SYS/g $PLOT/sar.ptpl|\ follow the link to see the template
sed s/%START/$START/g|sed s/%END/$END/g|sed s/%DAY/$DAY/g|\
sed s/%I/$I/g > $PLOT/sar.p; the final inputfile for ploticus
$PLOT/pl $PLOT/sar.p -gif ;
STAMP=`date "+%y%m%d%H%M%S"`;
mv $PLOT/sar.gif $OUT/sar_$SYS$STAMP.gif;
echo "<p><a href=/plots/sar_$SYS$STAMP.gif target=_blank>\
<img src=/plots/sar_$SYS$STAMP.gif align=right width=380 height=200></a>";;
a small picture is displayed, with a link to the great picture in a new window
esac
case $OPT in
a) OPT_TEXT="file access system routines";;
b) OPT_TEXT="buffer activity for transfers, accesses, cache hit";;
c) OPT_TEXT="system calls";;
k) OPT_TEXT="kernel process activity";;
m) OPT_TEXT="message (send/receive) and semaphore (create, use, destroy) activities";;
q) OPT_TEXT="average number of kernel threads in run queue";;
r) OPT_TEXT="paging statistics";;
u) OPT_TEXT="system-wide statistics (default)";;
v) OPT_TEXT="status of process, kernel-thread, i-node, file tables";;
w) OPT_TEXT="system switching activity";;
y) OPT_TEXT="tty device activity per second";;
esac
echo "<H2>SAR Report on <I>$SYS</I>:<BR>$OPT_TEXT</H2><PRE>" the raw sar numbers will be displayed
remsh $SYS -l root /usr/sbin/sar -s $START:00 -e $END:01 -f /var/adm/sa/sa$DAY -i $I -$OPT
fi
echo "</pre><br clear=all><HR></P><p>"
done
|