#!/bin/sh
#
# chk_cp
#
# Usage: chk_cp
#
# By: Angel Corbera, TSID1, Refinery Isla, Curacao, N.A.
# Comments to: [email protected]
#
# Purpose: Get and RESET counters from all CP's STATION blocks.
# Run it periodically (every week?) by crontab to
# watch CPs performance.
# The counters are RESET immediately after their values are captured.
#
# Original Version: 25may97
#
echo "\nThis script will get and RESET counters from all CP station blocks!"
echo "If you want just to get the current values, run 'g_cpstat' instead."
echo "Do you want to continue (y/n)?"
read answer
if [ $answer != "y" ]
then
echo "Exiting!"
exit 1
fi
echo "\n"
echo "IDLETM = Idle Time; CUMOVR = Cmpnd/Blk Overruns; OMOVRN = OM Overruns"
echo "PIOE1R = FB Retries; PIOEFT = Fault Tolerant Output mismatches"
echo "PIOEGB = Good->Bad FBM state changes; PP_NFD = Points NOT Found"
echo "\n CPs Report "
echo "-----------------------------------------------------------------"
sort /usr/fox/sp/hldb > tmp1
CP10=`awk '$2=="201" {print $1}' tmp1`
CP30=`awk '$2=="203" {print $1}' tmp1`
CP40=`awk '$2=="205" {print $1}' tmp1`
ABST=`awk '$2=="204" {print $1}' tmp1`
GET=/opt/fox/bin/tools/omget
SET=/opt/fox/bin/tools/omset
echo "CPLBUG IDLETM CPLOAD CUMOVR OMOVRN PIOE1R PIOEFT PIOEGB PP_NFD"
for x in $CP10 $CP30 $CP40 $ABST
do
$SET -v -i 0 "$x"_STA:STATION.LODPHS
$SET -v -i 5 "$x"_STA:STATION.LODPER
$SET -v -b TRUE "$x"_STA:STATION.LODSYN
$SET -v -b TRUE "$x"_STA:STATION.LODSW
sleep 5
$GET "$x"_STA:STATION.IDLETM | awk '{ a="'$x'"}{printf "\n%-7s\t%5.1f",a,$3 }'
$GET "$x"_STA:STATION.CPLOAD | awk '{printf "\t%5.2f",$3 }'
$GET "$x"_STA:STATION.CUMOVR | awk '{printf "\t%7d",$3 }'
$GET "$x"_STA:STATION.OMOVRN | awk '{printf "\t%7d",$3 }'
$GET "$x"_STA:STATION.PIOE1R | awk '{printf "\t%7d",$3 }'
$GET "$x"_STA:STATION.PIOEFT | awk '{printf "\t%7d",$3 }'
$GET "$x"_STA:STATION.PIOEGB | awk '{printf "\t%7d",$3 }'
$GET "$x"_STA:STATION.PP_NFD | awk '{printf "\t%3d",$3 }'
$SET -v -b TRUE "$x"_STA:STATION.RSOMOV
sleep 1
$SET -v -b TRUE "$x"_STA:STATION.RESOVR
sleep 1
$SET -v -b TRUE "$x"_STA:STATION.PIORST
sleep 1
$SET -v -b FALSE "$x"_STA:STATION.LODSW
done
echo "\n"
rm tmp1