#!/bin/ksh

##
## Script: chk_ctlds_procs.ksh
## Purpose: Check the number of ctlds processes on the pweb servers and also the number of database connections on port 4100
## Invoked From:  Normally run on pdb01 or pdb00
## Parameters:  none
## Depends on: 
## Requires:  
## Date Written:  01/08/2001
## Written By:  Michael O'Sullivan
## Revision History:
##

## Summary:  If the number of ctlds processes exceeds 10 on any of the pweb servers then that server will not function properly.
## The maximum number of database connections is set to 7000 and the database needs to be restarted if it exceeds this figure.

for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 23 24 25 26 27 28 29 30 31 32;
do
#rsh pweb$i 'dos2unix /opt/BMC/PATROL/Solaris26-sun4/lib/knowledge/CPU.km /opt/BMC/PATROL/Solaris26-sun4/lib/knowledge/CPU.km'
echo "processing pweb$i ..."
rsh pweb$i "ps -ef | grep -i patrol"
#SNMP_PID=$(rsh pweb$i ps -ef | grep -i snmpmagt | grep -i BMC | awk '{print $2}')
#if [ -z $SNMP_PID ]; then
  #KILLSTR="echo 'no snmpmagt to kill'"
#else
  #KILLSTR="kill ${SNMP_PID}"
#fi
#rsh pweb$i "${KILLSTR}"
#rsh pweb$i "/etc/rc2.d/S99patrolagent stop" &
#rsh pweb$i "/etc/rc2.d/S99patrolagent start" &
#rsh -n pweb$i "ps -ef | grep -i patrol; echo stopping; /etc/rc2.d/S99patrolagent stop; echo starting; /etc/rc2.d/S99patrolagent start; sleep 10; ps -ef | grep -i patrol" &
#sleep 30
done
