Cover V01, I04
Article
Listing 1

nov92.tar


Listing 1

############################################################################
###                   The System Performance Monitor                     ###
###                                    by,                               ###
###                                      Bill Genosa                     ###
############################################################################

### The number of concurrent users.
###-------------------------------------------------------------------------

USERS=`who | wc -l`                         ### Total number of users both
### direct and network sessions

NUSERS=`who | grep tty[a-z] | wc -l`        ### Count pseudo tty's in use

### The runqueue or number of processes in memory waiting execution.
###-------------------------------------------------------------------------

RUNQ=`sar -q | grep -v Aver | tail -2 | awk '{print $2}'`

### The percentage of time that the runqueue is occupied.
###-------------------------------------------------------------------------

RUNOCC=`sar -q | grep -v Aver | tail -2 | awk '{print $3}'`

### Process table utilization.
###-------------------------------------------------------------------------

PROC=`sar -v | grep -v Aver | tail -2 | awk '{print $2}'`  ### Gives ratio.

PROCALA=`echo $PROC | awk '-F/' '{print $1}'`              ### Entries used.

### File table utilization.
###-------------------------------------------------------------------------

FILE=`sar -v | grep -v Aver | tail -2 | awk '{print $6}'`  ### Gives ratio.

FILEALA=`echo $FILE | awk '-F/' '{print $1|}'`             ### Entries used.

### Memory utilization.
###-------------------------------------------------------------------------

MEM=`sar -r | grep -v Aver | tail -2 | awk '{print $2}'`   ### Free pages.

SWAP=`sar -w | grep -v Aver | tail -2 | awk '{print $4}'`  ### Swaps/sec.

SWCH=`sar -w | grep -v Aver | tail -2 | awk'{print $6}'`   ### Processes
### switched.

FLT=`sar -p | grep -v Aver | tail -2 | awk '{print $2}'`   ### Address page
### faults.

### Disk cache buffer utilization.
###-------------------------------------------------------------------------

RCACHE=`sar -b | grep -v Aver | tail -2 | awk '{print $4}'` ### Read hits.

WCACHE=`sar -b | grep -v Aver | tail -2 | awk '{print $7}'` ### Write hits.

### Terminal and printer activity.
###-------------------------------------------------------------------------

REC=`sar -y | grep -v Aver | tail -2 | awk '{print $2}'`   ### Raw char's
### received.
XMT=`sar -y | grep -v Aver | tail -2 | awk '{print $4}'`   ### Raw char's
### transmitted.

### Network interface statistics.
###-------------------------------------------------------------------------

NETXMT=`nistat -b 0 | grep "Packets transmitted" | awk '{print $5}'`

NETCOL=`nistat -b 0 | grep "Transmit collisions" | awk '{print $3}'`

NETROC=`echo "$NETCOL*100/$NETXMT" | bc`  ### Collisions multiplied by 100
### and divided by the number
### of packets that were xmitted
### equals the rate of collision.
nistat -c > /dev/null                     ### Clear all ni statistics.

### Clear the screen and output the information to a terminal.
###-------------------------------------------------------------------------

tput clear > /dev/tty22                   ### Clear the screen

echo "\n"
echo "  T H E   S Y S T E M   P E R F O R M A N C E   M O N I T O R"
echo "\n"
echo This report was generated at `date`.
echo There is a total of $USERS logged into the system.
echo There are $NUSERS logged in across the network.
echo There are $RUNQ runnable jobs in memory waiting for the CPU.
echo The runqueue is occupied $RUNOCC percent of the time.
echo The process table utilization is $PROC.
echo The file table utilization is $FILE.
echo The number of free memory pages is $MEM.
echo There are $SWAP pages\/sec of memory being swapped to disk.
echo There are $SWCH processes being switched.
echo There are $FLT address translation faults.
echo The disks are hitting cache $RCACHE percent on read operations.
echo The disks are hitting cache $WCACHE percent on write operations.
echo There are $REC raw characters\/sec being received from terminals.
echo There are $XMT characters\/sec being xmitted to terminals and printers.
echo The network has a $NETROC percent rate of collision.

### Alert the System Administrator if thresholds are exceeded.
###-------------------------------------------------------------------------

if [ $PROCALA -ge 800 ]                ### Process table configured for 850.
then
echo Message from the System Performance Monitor at `date`. > /dev/console
echo The process table utilization is $PROC.                > /dev/console
echo ^G^G^G^G^G                              > /dev/console ### ^G = bell.
fi

if [ $FILEALA -ge 1600 ]               ### File table configured for 1600.

then
echo Message from the System Performance Monitor at `date`. > /dev/console
echo The file table utilization is $FILE.           > /dev/console
echo ^G^G^G^G^G                             > /dev/console  ### ^G = bell.
fi

if [ $MEM -le 50 ]                     ### GPGSLO is configured for 25.
then
echo Message from the System Performance Monitor at `date`. > /dev/console
echo The number of free memory pages is $MEM.               > /dev/console
echo ^G^G^G^G^G                             > /dev/console  ### ^G = bell.
fi

if [ $NUSERS -ge 54 ]                  ### Maximum TCP sessions is 64.
then
echo Message from the System Performance Monitor at `date`. > /dev/console
echo There are $NUSERS logged in across the network.        > /dev/console
echo ^G^G^G^G^G                             > /dev/console  ### ^G = bell
fi

### Sar is set to run every 10 minutes on this machine.  Set the
### Performance Monitor to sleep 10 minutes between executions.
###-------------------------------------------------------------------------

sleep 600

exec /usr/admin/progs/sysperfmon > /dev/tty22

###------------------------------- E N D -----------------------------------