Loops thru the sap_systems.ctl to find out all SIDs
and servers and checks for SAP processes
Requires :
func_lib.sh -- function library
systems.ctl-- Control file with configuration of SAP systems
#!/bin/ksh
UTL_SHELL=/sapglobal/SHELL
UTL_BIN=$UTL_SHELL
export UTL_SHELL UTL_BIN
pgm="sap_up"
. $UTL_BIN/func_lib.sh
DATE="`date '+%D-%H:%M'`"
CHECK_INSTANCE="$UTL_BIN/check_instance"
if [ $(id -u) -ne 0 ]
then
echo "userid=`id -u`, must be run as root"
#exit
fi
localhost=`hostname`
if [ ${1}x = ""x ] ;then
echo "Usage: $pgm \n"
echo "Modes indicate the output format from this program "
echo " mode=1 -- display just the #of running processes and
# of configured procs."
echo " mode=2 -- display detailed info of each apps. instance
(default)"
echo " mode=3 -- display the hostname:DATETIME:#of running procs:
#of conf. procs."
exit 0
fi
# Modes indicate what should be the return output from check_instance ()
# Mode=1 -- display just the #of running processes and # of configured procs.
# Mode=2 -- display detailed info of each apps. instance (default)
# Mode=3 -- display the hostname:DATETIME:#of running procs:#of conf. procs.
if [ "$2"x = ""x -o "$2"x = "2"x ];then
mode="2"
elif [ $2 = "1" ];then
mode="1"
elif [ $2 = "3" ];then
mode="3"
fi
if [ $mode = "2" ];then
# echo "Start of SAP / ORACLE process monitor on `date '+%m/%d/%y-%H:%M'` "
awk \
'BEGIN {print("Host
SID Configured DSP MSG DIA VB ENQ BTC SPO GWY Active Instance Status");
print("---- --- ---------- --- --- --- --
--- --- --- --- ------ -------- ------")}'
fi
if [ $1 = "all" ]
then
for ln in `cut -d"|" -f1-6 $UTL_BIN/sap_systems.ctl | grep '^[AZI]`
do
serv=`echo $ln | cut -d"|" -f1` # Central or Apps instance
sid=`echo $ln | cut -d"|" -f2` # Which SID?
host=`echo $ln | cut -d"|" -f3` # Which host?
inst=`echo $ln | cut -d"|" -f4` # Instance number?
name=`echo $ln | cut -d"|" -f6` # Instance name?
userid=`echo $sid | tr "[A-Z]" "[a-z]"`adm
if [ $serv = "I" ];then
serv="A"
fi
if [ ! -f $UTL_ROOT/systems/${sid}.${host}.down ]
then
if [ $host != $localhost ]
then
remsh $host -l $userid -n $CHECK_INSTANCE \
$sid $host $name $inst $serv $mode 2>/dev/null
[ $? -ne 0 ] && \
echo "Not checking $sid, remote login to $host as
$userid failed, .rhosts not setup"
else
$CHECK_INSTANCE $sid $host $name $inst $serv $mode
fi
else
echo "$host $sid" | \
awk '{printf("%8-s %3-s < Shutdown normally for maintenance\n",$1,$2)}'
fi
done
else
validate_sid $1
if [ $? -ne 0 ];then
validate_host $1
if [ $? -ne 0 ];then
echo "Invalid argument $1, can be a hostname or an ORACLE SID"
exit 2
else
get_sids $1
fi
else
SIDS=$1
fi
for sid in $SIDS
do
userid=`echo $sid | tr "[A-Z]" "[a-z]"`adm
get_apps_hosts $sid
for apps_server in $APPS_HOSTS
do
if [ ! -f $UTL_ROOT/systems/${sid}.${apps_server}.down ]
then
get_primary_instance_name $sid $apps_server
remsh $apps_server -l $userid -n $CHECK_INSTANCE \
${sid} $apps_server $NAME $NUMBER $TYPE $mode 2>/dev/null
get_secondary_instance_names $sid $apps_server
if [ $? -gt 0 ];then # returns # of sec. apps. server
remsh $apps_server -l $userid -n $CHECK_INSTANCE \
${sid} $apps_server $S_NAME $S_NUMBER "A" $mode 2>/dev/null
fi
[ $? -ne 0 ] && \
echo "Not checking $sid, remote login to
$apps_server as $userid failed, .rhosts not setup"
else
echo "$apps_server $sid" | \
awk '{printf("%8-s %3-s
< Shutdown normally for maintenance\n",$1,$2)}'
fi
done
get_db_host $sid
get_primary_instance_name $sid $DB_HOST
if [ ! -f $UTL_ROOT/systems/${sid}.${DB_HOST}.down ]
then
if [ $DB_HOST != $localhost ]
then
remsh $DB_HOST -l $userid -n "$CHECK_INSTANCE \
$sid $DB_HOST $NAME $NUMBER $TYPE $mode" 2>/dev/null
[ $? -ne 0 ] && \
echo "Not checking $sid, remote login to
$DB_HOST as $userid failed, .rhosts not setup"
else
$CHECK_INSTANCE $sid $DB_HOST $NAME $NUMBER $TYPE $mode
fi
else
echo "$DB_HOST $sid" | \
awk '{printf("%8-s %3-s < Shutdown normally for maintenance\n",$1,$2)}'
fi
done
fi