#!/bin/sh
#
#  g_cpstat
#
#  Usage:  g_cpstat
#
#  By:  Angel Corbera, TSID1, Refinery Isla, Curacao, N.A.
#  Comments to:  corbera@rocketmail.com
#
#  Purpose:  Get data from all CP's STATION blocks.
#            Run it manually anytime you want to take a look at
#            CP's performance.
#            Run 'chk_cp' if you want to get/reset the counters.
#
#  Original Version: 22may97
#
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 FALSE "$x"_STA:STATION.LODSW
done
echo "\n"
rm tmp1
1