File: //opt/perf/bin/ovpa
#!/bin/sh
#Usage:ovpa [status|start|stop|restart|version] [scope|server|alarm|all]
#==============================================================================
# @(#)ovpa script 11.00.012 =*=
#
# This script performs basic startup and shutdown functions for the
# various subsystems of the HP Performance Agent (Perf Agent).
# This script can be invoked as "mwa", which is supported to be backward
# compatible with Perf Agent3.x versions and as "ovpa".
# The command line parameters and functions that are valid are:
#
# ovpa <action> <subsys>
#
# <action> status Report the daemon processes which are/not running
# start Start any daemon processes which are not running
# Use "start fast" for faster startup of daemon
# processes during system startup sequence.
# stop Terminate daemon processes.
# Use "stop fast" for faster termination of daemon
# processes during system shutdown sequence.
# restart Terminate then start the daemon processes. This
# forces the daemons to reprocess their configuration
# files and reinitialize themselves.
# version Check whatstrings of product executables.
# demo Runs the ovpademo script
#
# <subsys> scope The Perf Agent system performance collector
# alarm The alarming daemon (perfalarm)
# server The data server (coda) and alarming daemon
# (perfalarm)
# [if no subsys is specified, then the action is
# performed on all above subsystems]
#
# SPECIAL ACTIONS:
#
# -ps psfile This file only for use from perfstat to pass in
# the name of the ps output file for efficiency.
#
# -midaemon miparms Used with "start scope" only. Pass the midaemon
# startup parameters "miparms", for example:
# ovpa start scope -midaemon -pids 20000
#
# NOTE: If the -midaemon parameter is used, it must be the last
# parameter in the list. All remaining parameters will be passed
# to the midaemon process.
#
#============================================================================
# Note to developers: If you make any changes to this script, take care
# to insure that if the script is run non-interactively, then it will never
# perform a read to stdin. This script may be called as a part of the system
# startup processing and reading from stdin could hang the process!!
#============================================================================
#
# Performance Technology Center
# Hewlett-Packard
#
#==============================================================================
printusage() {
echo ""
echo "Usage = ovpa <action> <subsys>"
echo " <action> = status, start, stop, restart, demo, version"
echo " <subsys> = server, alarm, all"
echo " "
echo " <action> and <subsys> may be entered in any order"
echo " but if <parms> is supplied, then it must be entered last"
echo ""
echo " <parms> = -midaemon <miparms>"
echo " See man midaemon for <miparms>"
echo ""
echo " Defaults: <action>=start, <subsys>=all, <parms>=\"\""
echo
echo " <subsys> = <perf> applicable only with <status>"
echo " prints ovpa performance process status in ovc format"
echo
} # printusage
#==============================================================================
PurgePAPSFILE () {
# Note: clean up ps output tmp file only if ovpa script created it
# (just rm-ing $PSFILE would hurt perfstat:
if [ -f "$PAPSFILE" ]; then
rm -f $PAPSFILE
fi
} # PurgePAPSFILE
#==============================================================================
getnewpidlist() {
# generate a "ps" list to a file for later processing by pidlist
if [ ! -f "$PAPSFILE" ]; then
if [ "$MKTEMP" = "X" ]; then
PAPSFILE="/var/tmp/ovpaps$$"
else
PAPSFILE=`$MKTEMP $MKTEMP_OPTS ovpaps.$$.XXXXXXXXXX 2>/dev/null`
if [ $? -ne 0 ]; then
PAPSFILE="/var/tmp/ovpaps$$"
fi
fi
fi
$PS | cut -c 1-150 |tr -d '[\[]' |tr -d '[\]]' >$PAPSFILE
if [ $? -ne 0 -o ! -s $PAPSFILE ]
then
echo "$PAPSFILE creation failed."
NiceOVPAExit 1
fi
} # getnewpidlist
#==============================================================================
pidlist_p() {
# Print list of pids for which command name matches text passed as arg:
awk 'BEGIN { ORS=" " } \
$stime ~ /:/ { n=split($cmd1,arr,"/"); \
if ("'$*'" == arr[n]) print $pf; \
if ("'[$*]'" == arr[n]) print $pf; next } \
$cmd2 ~ /'$*'/ { n=split($cmd2,arr,"/"); \
if ("'$*'" == arr[n]) print $pf; \
if ("'[$*]'" == arr[n]) print $pf } ' \
stime=$STIMEFIELD cmd1=$CMDFIELD1 \
cmd2=$CMDFIELD2 pf=$PIDFIELD $PAPSFILE
} # end pidlist_p
pidlist() {
PIDLIST=`pidlist_p "$*"`
return `echo $PIDLIST | wc -w`
} # end pidlist
mwa_pidlist() {
# Return list of pids which contain text passed as args:
PIDLIST=`awk 'BEGIN { ORS=" " } \
$stime ~ /:/ { if ($cmd1 ~ /'$*'/) print $pf; next } \
$cmd2 ~ /'$*'/ { print $pf } ' \
stime=$STIMEFIELD cmd1=$CMDFIELD1 \
cmd2=$CMDFIELD2 pf=$PIDFIELD $PAPSFILE`
return `echo $PIDLIST | wc -w`
} # end pidlist
#==============================================================================
sets() {
# set shell variables according to host.
# the variable PIDFIELD then gets set to identify a field in the "ps" command.
# Note that for efficiency sake, we may want to pass the /tmp filename
# generated in perfstat into this script to avoid repeated calls to the
# ps command. Especially on large systems, this is a performance killer.
LANG_FROM_ENV=$LANG
LC_ALL_FROM_ENV=$LC_ALL
LANG=C
export LANG
LC_ALL=C
export LC_ALL
SYS="`uname -s`"
REV="`uname -r`"
ARCH_NAME="`uname -m`"
VMWARE=" "
if [ `which mktemp 2>&1|grep "no mktemp"|wc -l` -eq 0 ]; then
MKTEMP="mktemp"
else
MKTEMP="X"
fi
case "$SYS" in
HP-UX)
SYS="HP-UX"
PS="/bin/ps -ef"
if [ "$ARCH_NAME" = "ia64" ]; then
SUB_LIB_DIR="/hpux64"
LIBEXT=".so"
else
SUB_LIB_DIR=""
LIBEXT=".sl"
fi
OVPA_BIN_DIR="/opt/perf/bin"
OVPA_LIB_DIR="/opt/perf/lib$SUB_LIB_DIR"
OVPA_DATA_DIR="/var/opt/perf/datafiles"
OVPA_CONF_DIR="/var/opt/perf"
OVPA_NEWCONF_DIR="/opt/perf/newconfig"
OVPA_METDESC_DIR="/opt/perf/lib"
DEFAULT_OVPA_FILE="/etc/rc.config.d/ovpa"
OV_BIN_DIR="/opt/OV/bin"
OV_LIB_DIR="/opt/OV/lib"
OV_MAN_DIR="/opt/OV/man"
OV_CONF="/var/opt/OV/conf"
OV_LBIN_DIR="/opt/OV/lbin/"
M10ICODA_DIR="/opt/OV/lbin/perf"
REV="11"
# if no command option is given, use the contents of this file:
if [ -f "$DEFAULT_OVPA_FILE" ]; then
. $DEFAULT_OVPA_FILE
fi
MKTEMP_OPTS="-d /var/tmp -p"
;;
Sun*)
SYS="SUN"
if [ `uname -p` = i386 ];
then
PLAT="i386"
else
PLAT=""
fi
OSVER=`echo $REV | cut -f2 -d .`
if [ $OSVER -ge 10 ] && [ -x /usr/bin/zonename ]; then
ZONENAME=`zonename`
if [ $? -eq 0 ] && [ $ZONENAME = "global" ]; then
PS="ps -fz global"
else
PS="ps -ef"
fi
else
PS="ps -ef"
fi
OVPA_BIN_DIR="/opt/perf/bin"
OVPA_LIB_DIR="/opt/perf/lib"
OVPA_DATA_DIR="/var/opt/perf/datafiles"
OVPA_CONF_DIR="/var/opt/perf"
OVPA_NEWCONF_DIR="/opt/perf/newconfig"
OVPA_METDESC_DIR="/opt/perf/lib"
DEFAULT_OVPA_FILE="/etc/default/ovpa"
OV_BIN_DIR="/opt/OV/bin"
OV_LIB_DIR="/opt/OV/lib"
OV_MAN_DIR="/opt/OV/man"
OV_CONF="/var/opt/OV/conf"
OV_LBIN_DIR="/opt/OV/lbin/"
M10ICODA_DIR="/opt/OV/lbin/perf"
LIBEXT=".so"
# if no command option is given, use the contents of this file:
if [ -f "$DEFAULT_OVPA_FILE" ]; then
. $DEFAULT_OVPA_FILE
fi
MKTEMP_OPTS="-p /var/tmp -q"
;;
Linux*)
SYS="LINUX"
# Don't know why other platforms try to source default file
PS="eval ps -ef 2>/dev/null" # Debian can output error messages.
OVPA_BIN_DIR="/opt/perf/bin"
OVPA_LIB_DIR="/opt/perf/lib"
OVPA_LIB64_DIR="/opt/perf/lib64"
OVPA_DATA_DIR="/var/opt/perf/datafiles"
OVPA_CONF_DIR="/var/opt/perf"
OVPA_NEWCONF_DIR="/opt/perf/newconfig"
OVPA_METDESC64_DIR="/opt/perf/lib64"
OVPA_METDESC_DIR="/opt/perf/lib"
DEFAULT_OVPA_FILE="/etc/sysconfig/ovpa"
OV_BIN_DIR="/opt/OV/bin"
OV_LIB_DIR="/opt/OV/lib"
OV_LIB64_DIR="/opt/OV/lib64"
OV_MAN_DIR="/opt/OV/man"
OV_CONF="/var/opt/OV/conf"
OV_LBIN_DIR="/opt/OV/lbin/"
M10ICODA_DIR="/opt/OV/lbin/perf"
LIBEXT=".so"
# Only for the VMWare systems
if [ -d /proc/vmware ]; then
VMWARE="vmware"
fi
# if no command option is given, use the contents of this file:
if [ -f "$DEFAULT_OVPA_FILE" ]; then
. $DEFAULT_OVPA_FILE
fi
MKTEMP_OPTS="-p /var/tmp -q"
;;
*)
SYS="AIX"
unset LIBPATH
unset LD_LIBRARY_PATH
OVPA_LIB64_DIR="/usr/lpp/perf/lib64"
OVPA_METDESC64_DIR="/usr/lpp/perf/lib64"
OV_LIB64_DIR="/usr/lpp/OV/lib64"
OVPA_LIB_DIR="/usr/lpp/perf/lib"
OVPA_METDESC_DIR="/usr/lpp/perf/lib"
if [ "$INSTALLED_BITS" = "64" ]; then
PS="ps -ef -@ Global"
else
PS="ps -ef"
fi
OVPA_BIN_DIR="/usr/lpp/perf/bin"
OVPA_DATA_DIR="/var/opt/perf/datafiles"
OVPA_CONF_DIR="/var/opt/perf"
OVPA_NEWCONF_DIR="/usr/lpp/perf/newconfig"
DEFAULT_OVPA_FILE="/etc/default/ovpa"
OV_BIN_DIR="/usr/lpp//OV/bin"
OV_LIB_DIR="/usr/lpp/OV/lib"
OV_MAN_DIR="/usr/lpp/OV/man"
OV_CONF="/var/opt/OV/conf"
OV_LBIN_DIR="/usr/lpp/OV/lbin/"
M10ICODA_DIR="/usr/lpp/OV/lbin/perf"
LIBEXT=".a"
# if no command option is given, use the contents of this file:
if [ -f "$DEFAULT_OVPA_FILE" ]; then
. $DEFAULT_OVPA_FILE
fi
MKTEMP="X"
;;
esac
# Libraries in OV directory
OVPA_BINLIST="perfalarm utility dsilog \
sdlcomp sdlutil agsysdb"
OVPA_LIBLIST="libscope$LIBEXT libnums$LIBEXT libarm$LIBEXT libarmNOP$LIBEXT liblicense$LIBEXT"
if [ "$VMWARE" != "vmware" ]; then
OVPA_BINLIST="ttd midaemon $OVPA_BINLIST"
fi
OV_LIBLIST="libOvScopeAccess$LIBEXT"
OVPA_LIBLIST_CODA="libOvDirectAccess$LIBEXT"
if [ "$SYS" = "AIX" ]; then
OVPA_BINLIST="$OVPA_BINLIST lsdaemon"
OVPA_LIBLIST="$OVPA_LIBLIST libarmns$LIBEXT"
OV_LIBLIST="libOvScopeAccess.so"
OVPA_LIBLIST_CODA="libOvDirectAccess.so"
fi
USERID=`/usr/bin/id | cut -d'(' -f1 | cut -d= -f2`
USERNAME=`/usr/bin/id | cut -d'(' -f2 | cut -f1 -d')'`
# if this script was called from perfstat then PSFILE should
# be defined, otherwise define it now:
STANDALONE=0
if [ ! -f "$P_PSFILE" ]; then
getnewpidlist
STANDALONE=1
else
if [ "$MKTEMP" = "X" ]; then
PAPSFILE="/var/tmp/ovpaps$$"
else
PAPSFILE=`$MKTEMP $MKTEMP_OPTS ovpaps.$$.XXXXXXXXXX 2>/dev/null`
if [ $? -ne 0 ]; then
PAPSFILE="/var/tmp/ovpaps$$"
fi
fi
cat $P_PSFILE | cut -c 1-150|tr -d '[\[]' |tr -d '[\]]' > $PAPSFILE
fi
# determine position of PID field in PS output
# (will differ by platform)
PIDFIELD=1
set `sed -n 1p $PAPSFILE`
while [ "X$1" != "XPID" ]
do
PIDFIELD=`expr $PIDFIELD + 1`
shift
done
# Determine position of STIME (sometimens STARTED) field in PS output
# (will differ between Sun, HP-UX, and "fair share scheduler" systems)
STIMEFIELD=1
set `sed -n 1p $PAPSFILE`
while [ "X$1" != "XSTIME" -a "X$1" != "XSTARTED" ]
do
STIMEFIELD=`expr $STIMEFIELD + 1`
shift
done
# Because time fields may look like one OR two fields to awk, need to
# assign two possible positions for command fields:
CMDFIELD1=1
set `sed -n 1p $PAPSFILE`
while [ "X$1" != "XCOMMAND" -a \
"X$1" != "XCMD" -a \
"X$1" != "XCOMD" ]
do
CMDFIELD1=`expr $CMDFIELD1 + 1`
shift
done
# Date format - Linux says Aug23, other unix Aug 23 so on Linux
# do not add 1 for CMDFIELD2. Set $TAB, also.
if [ "$SYS" = "LINUX" ]; then
TAB=`echo -e '\t'`
CMDFIELD2=`expr $CMDFIELD1`
else
TAB=`echo '\t'`
CMDFIELD2=`expr $CMDFIELD1 + 1`
fi
# Return value for perfstat, assume success:
OOPS=0
# For file/directory ownership
OV_OWNER=root:bin
# ovo switch user variables
CONF_TOOL="${OV_BIN_DIR}/ovconfget"
OVPA_OV_SUDO=""
OVPA_OV_SUDO_USER=""
OVPA_OV_SUDO_GROUP=""
OVPA_OV_MODE=""
OVPA_NPU_TASK=""
OVO_NPU_CMD=""
PA_NPU_CMD=""
USERID=`/usr/bin/id | cut -d'(' -f1 | cut -d= -f2`
if [ -x ${CONF_TOOL} ]; then
OVPA_OV_MODE=`${CONF_TOOL} eaagt |grep "^MODE=" | awk -F= '{print $2}' | grep -v \"\"`
OVPA_NPU_TASK=`${CONF_TOOL} eaagt |grep "^NPU_TASK_SET=" | awk -F= '{print $2}' | grep -v \"\"`
OVPA_OV_SUDO=`${CONF_TOOL} |grep "^OV_SUDO=" | awk -F= '{print $2}' | grep -v \"\"`
OVPA_OV_SUDO_USER=`${CONF_TOOL} |grep "^OV_SUDO_USER=" | awk -F= '{print $2}' | grep -v \"\"`
OVPA_OV_SUDO_GROUP=`${CONF_TOOL} |grep "^OV_SUDO_GROUP=" | awk -F= '{print $2}' | grep -v \"\"`
if [ "x${OVPA_OV_SUDO}" != "x" ] ; then
OVO_NPU_CMD="su - ${OVPA_OV_SUDO_USER} -c"
fi
if [ "x${OVPA_OV_MODE}" = "xNPU" -a "x${USERNAME}" != "x${OVPA_OV_SUDO_USER}" ] ; then
OVO_NPU_CMD="su - ${OVPA_OV_SUDO_USER} -c"
PA_NPU_CMD="su - ${OVPA_OV_SUDO_USER} -c"
fi
if [ "x${OVPA_OV_MODE}" = "xMIXED" ] ; then
if [ "x${OVPA_NPU_TASK}" = "xEVENT_ACTION" -a "x${USERNAME}" != "x${OVPA_OV_SUDO_USER}" ]; then
OVO_NPU_CMD="su - ${OVPA_OV_SUDO_USER} -c"
elif [ "x${OVPA_NPU_TASK}" = "xAGENT_COEX" -a "x${USERNAME}" != "x${OVPA_OV_SUDO_USER}" ]; then
PA_NPU_CMD="su - ${OVPA_OV_SUDO_USER} -c"
fi
fi
fi
} # end sets
#==============================================================================
mustberoot() {
# Check if user is root or superuser in non-NPU mode, if not, bail out
if [ "x${OVPA_OV_MODE}" != "xNPU" ]; then
if [ $USERID -ne 0 ]; then
echo "ERROR: This function must be executed by superuser (root)"
PurgePAPSFILE
NiceOVPAExit 1
fi
fi
} # mustberoot;
#==============================================================================
# SERVER Actions
#==============================================================================
#==============================================================================
# WaitForTerminate is used by the StopServer function. This function will
# display status messages while it is waiting for a process to terminate.
#==============================================================================
WaitForTerminate () {
MAX_STATUS_MSGS=$1 # How many times to display the status message
MAX_PROCESS_CHECKS=$2 # How many times to check for the process before displaying
# the next status message
SLEEP_TIME=$3 # How many seconds to sleep between each check for the process
PROCESS_NAMES=$4 # Name of processes to check for
STATUS_MSG=$5 # Status message
FIRST=1
MSGTIMES=$MAX_STATUS_MSGS
while [ $MSGTIMES -gt 0 ]
do
CHECKTIMES=$MAX_PROCESS_CHECKS
while [ $CHECKTIMES -gt 0 ]
do
getnewpidlist
pidlist "$PROCESS_NAMES"
if [ $? != 0 ]; then
/bin/sleep $SLEEP_TIME
CHECKTIMES=`expr $CHECKTIMES - 1`
else
# set to get out of the while loops
CHECKTIMES=0
MSGTIMES=0
fi
done
if [ $MSGTIMES -ge 1 ]; then
if [ $FIRST -eq 1 ]; then
FIRST=0
MSGINTERVAL=`expr $MAX_PROCESS_CHECKS \* $SLEEP_TIME`
echo " Status messages will be displayed every $MSGINTERVAL seconds"
fi
MSGTIMES=`expr $MSGTIMES - 1`
echo "$STATUS_MSG ($MSGTIMES more times)"
fi
done
} # WaitForTerminate
#==============================================================================
# PERFALARM ALARM Actions
#==============================================================================
StartAlarms () {
mustberoot
if [ -f /var/opt/perf/alarmdef ]; then
pidlist 'perfalarm'
if [ $? != 0 ]; then
# On Sun SIGUSR2 not available for use. Using SIGHUP instead.
if [ "$SYS" = "SUN" ]; then
kill -HUP $PIDLIST
else
kill -USR2 $PIDLIST
fi
echo " The alarm generator $OVPA_BIN_DIR/perfalarm is already running."
echo " It is signaled to reprocess its alarm definitions."
else
echo "The Perf Agent alarm generator is being started."
if [ "$FAST" = "fast" ]; then
if [ "x" != "x${PA_NPU_CMD}" ]; then
eval ${PA_NPU_CMD} \"LANG=$LANG_FROM_ENV LC_ALL=$LC_ALL_FROM_ENV $OVPA_BIN_DIR/perfalarm\" &
else
LANG=$LANG_FROM_ENV LC_ALL=$LC_ALL_FROM_ENV $OVPA_BIN_DIR/perfalarm &
fi
else
if [ "x" != "x${PA_NPU_CMD}" ]; then
eval ${PA_NPU_CMD} \"LANG=$LANG_FROM_ENV LC_ALL=$LC_ALL_FROM_ENV $OVPA_BIN_DIR/perfalarm\"
else
LANG=$LANG_FROM_ENV LC_ALL=$LC_ALL_FROM_ENV $OVPA_BIN_DIR/perfalarm
fi
fi
if [ $? -eq 0 ]; then
echo " The alarm generator $OVPA_BIN_DIR/perfalarm "
echo " has been started."
else
echo "ERROR: The alarm generator $OVPA_BIN_DIR/perfalarm "
echo " failed to execute."
startup_exit_status=1
fi
fi
fi
} # StartAlarms
#==============================================================================
StopAlarms () {
mustberoot
pidlist 'perfalarm'
if [ $? != 0 ]; then
echo
echo "Shutting down the alarm generator perfalarm, pid(s) $PIDLIST"
if [ "$FAST" = "fast" ]; then
kill -KILL $PIDLIST
else
kill -USR1 $PIDLIST
/bin/sleep 10
getnewpidlist
pidlist 'perfalarm'
if [ $? != 0 ]; then
kill -TERM $PIDLIST
/bin/sleep 5
getnewpidlist
pidlist 'perfalarm'
if [ $? != 0 ]; then
kill -KILL $PIDLIST
fi
fi
/bin/sleep 2
getnewpidlist
pidlist 'perfalarm'
if [ $? != 0 ]; then
echo "ERROR: The perfalarm process has not terminated"
else
echo " The perfalarm process has terminated"
fi
fi
fi
} # StopAlarms
#==============================================================================
RestartAlarms () {
mustberoot
pidlist 'perfalarm'
if [ $? != 0 ]; then
echo "The alarm generator is being signaled to reprocess" \
"its alarm definitions."
# On Sun SIGUSR2 not available for use. Using SIGHUP instead.
if [ "$SYS" = "SUN" ]; then
kill -HUP $PIDLIST
else
kill -USR2 $PIDLIST
fi
else
echo "WARNING: The alarm generator"
echo " $OVPA_BIN_DIR/perfalarm is not running."
echo " Please use the ovpa start alarm\" command to start it."
fi
echo
} # RestartAlarms
#==============================================================================
CheckAlarms () {
# Print the current status of the perfalarm alarm generator
pidlist 'perfalarm'
if [ $? != 0 ]; then
echo " Running perfalarm " \
"(alarm generator) pid(s) $PIDLIST"
else
if [ -f /var/opt/perf/alarmdef ]; then
echo "WARNING: perfalarm is not active (alarm generator)"
OOPS=1
fi
fi
} #CheckAlarms
#==============================================================================
# SCOPE Actions
#==============================================================================
StartScope () {
mustberoot
# Start the Perf Agent collector daemon
echo
echo "The Perf Agent collector is being started."
pidlist 'ttd'
if [ $? != 0 ]; then
echo " The ARM registration daemon ttd is already running."
if [ -x $OVPA_BIN_DIR/ttd ]; then
# resynchronize ttd with the midaemon
echo " It will be signaled to reprocess its configuration file."
$OVPA_BIN_DIR/ttd -hup -mi
fi
else
if [ -x $OVPA_BIN_DIR/ttd ]; then
# If ttd.pid file exists when ttd is not running, then
# remove that old file before starting ttd.
if [ -f /var/opt/perf/ttd.pid ]
then
rm -f /var/opt/perf/ttd.pid
fi
if [ "$FAST" = "fast" ]; then
if [ "x" != "x${PA_NPU_CMD}" ]; then
eval ${PA_NPU_CMD} \"$OVPA_BIN_DIR/ttd\" &
else
$OVPA_BIN_DIR/ttd &
fi
else
if [ "x" != "x${PA_NPU_CMD}" ]; then
eval ${PA_NPU_CMD} \"$OVPA_BIN_DIR/ttd\"
else
$OVPA_BIN_DIR/ttd
fi
fi
if [ $? -eq 0 ]; then
echo " The ARM registration daemon"
echo " $OVPA_BIN_DIR/ttd has been started."
else
echo "ERROR: The ARM registration daemon"
echo " $OVPA_BIN_DIR/ttd failed to execute."
result=1
startup_exit_status=1
fi
else
echo "ERROR: Unable to execute $OVPA_BIN_DIR/ttd program."
startup_exit_status=1
fi
fi
echo " "
CODA_PROC_NAME="oacore"
pidlist $CODA_PROC_NAME
if [ $? != 0 ]; then # CODA_PROC_NAME is already running
$CODAUTIL -config >/dev/null 2>&1 &
echo " The oacore daemon is already running."
return
else
if [ "x" != "x${OVO_NPU_CMD}" ]; then
# if ovpa-ovo commmon components are configured to run as non-root, then su to non-root and execute coda
echo "NOTE: OVO Agent is configured to run as (${OVPA_OV_SUDO_USER}). "
echo " Hence Perf Agent-OVO common daemons will run as (${OVPA_OV_SUDO_USER})"
eval ${OVO_NPU_CMD} \"$CODA_START >/dev/null 2>&1 \"
else
$CODA_START >/dev/null 2>&1
fi
echo " The oacore daemon has been started."
fi
echo " It will be fully operational in a few minutes."
echo " "
# Start the midaemon manually so parameters may be passed to it
if [ "X$MIPARMS" != "X" ]; then
if [ "x" != "x${PA_NPU_CMD}" ]; then
eval ${PA_NPU_CMD} \"$OVPA_BIN_DIR/midaemon $MIPARMS\"
else
$OVPA_BIN_DIR/midaemon $MIPARMS
fi
if [ $? -ne 0 ]
then
echo "ERROR: $OVPA_BIN_DIR/midaemon failed to execute."
startup_exit_status=1
fi
fi
} # StartScope
#==============================================================================
StopScope () {
mustberoot
echo
echo "Shutting down Perf Agent collection software"
result=0;
pidlist 'oacore'
if [ $? != 0 ]; then
echo " Shutting down oacore, pid(s) $PIDLIST"
if [ "$FAST" != "fast" ]; then
$OV_BIN_DIR/ovc -stop oacore
# Wait up to a minute for things to shut themselves down gracefully
WAITTIMES=10
while [ $WAITTIMES -gt 0 ]
do
/bin/sleep 6
getnewpidlist
pidlist 'oacore'
if [ $? != 0 ]; then
echo " Waiting on $PIDLIST ($WAITTIMES more tries)"
WAITTIMES=`expr $WAITTIMES - 1`
kill -TERM $PIDLIST >/dev/null 2>&1
else
WAITTIMES=0
fi
done
/bin/sleep 2
# Get nasty, try a kill -KILL as a more severe termination request
getnewpidlist
pidlist 'oacore'
if [ $? != 0 ]; then
echo "Issuing kill -KILL commands for pid(s) $PIDLIST"
kill -KILL $PIDLIST
fi
# give it a few more seconds:
/bin/sleep 10
getnewpidlist
pidlist 'oacore'
if [ $? != 0 ]; then
echo "ERROR: The Perf Agent pid(s) $PIDLIST"
echo " has not terminated"
CheckScope
result=1
fi
if [ $result -eq 0 ]; then
echo " The Perf Agent collector has been shut" \
"down successfully."
fi
fi # "$FAST" != "fast"
fi
if [ "$FAST" = "fast" ]; then
echo " The ARM daemons ttd, midaemon and Glance programs glance and xglance will be terminated (if running)."
pidlist 'glance'
if [ $? != 0 ]; then
kill -KILL $PIDLIST
fi
if [ "$SYS" = "LINUX" ]
then
pidlist 'xglance-bin'
else
pidlist 'xglance'
fi
if [ $? != 0 ]; then
kill -KILL $PIDLIST
fi
$OVPA_BIN_DIR/ttd -k
$OVPA_BIN_DIR/midaemon -T
else
echo "NOTE: The ARM registration daemon ttd will be left running."
fi
} # StopScope
#==============================================================================
CheckScope () {
# Print the current status of the Perf Agent collector daemon
echo " Perf Agent status:"
pidlist 'utility'
if [ $? != 0 ]; then
echo " Running utility " \
"(Perf Agent analysis program) pid $PIDLIST"
fi
pidlist 'midaemon'
if [ $? != 0 ]; then
for i in $PIDLIST; do
id=`ps -p $i -f | grep midaemon | awk '{printf "%d\n",$3}' `
parent_found=0
for j in $PIDLIST; do
if [ $j = $id ]; then
parent_found=1
break;
fi
done
if [ $parent_found = 0 ]; then
echo " Running midaemon " \
"(Measurement Interface daemon) pid $i"
break
fi
done
else
echo "WARNING: midaemon is not active (Measurement Interface daemon)"
OOPS=1
fi
pidlist 'ttd'
if [ $? != 0 ]; then
echo " Running ttd " \
"(ARM registration daemon) pid $PIDLIST"
else
echo "WARNING: ttd is not active (ARM registration daemon)"
OOPS=1
fi
if [ "$SYS" = "AIX" ]; then
pidlist 'lsdaemon'
if [ $? != 0 ]; then
echo "\n Running lsdaemon (logical systems daemon) with the following pid and ppid \n" \
" PID PPID "
id=`ps -eaf|grep .\[l]sdaemon\ * |awk '{printf "\t\t\t\t %d %d\n", $2, $3}' `
echo "$id" > /var/tmp/ls_pid.txt
for i in $PIDLIST; do
grep $i /var/tmp/ls_pid.txt 2>/dev/null # print only the pid related to binary
done
rm -f /var/tmp/ls_pid.txt 2>/dev/null
fi
fi
} # CheckScope
#=========================================================
# Check if license is available for a given compnent
# returns 1, if license is available
# returns 0, if license is not available
#=========================================================
IsLicAvailable() {
retVal=0
if [ $# -gt 0 ]; then
OUTPUT=`$OV_BIN_DIR/oalicense -check $1`
if [ "$OUTPUT" = "Success" ]; then
retVal=1
fi
fi
return $retVal
}
#==============================================================================
# Check Performance Process and print status in OVC Format
#==============================================================================
CheckPerf () {
if [ "$SYS" = "LINUX" ]
then
pidlist 'xglance-bin'
else
pidlist 'xglance'
fi
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "xglance glance motif interface %-9sRunning\n",$1}'
done
fi
pidlist 'glance'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "glance glance character-mode interface %-9sRunning\n",$1}'
done
fi
IsLicAvailable "PA"
if [ $? != 0 ]; then
pidlist 'scopeux'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "scopeux Perf Agent data collector %-9sRunning\n",$1}'
done
else
ip=""
fi
fi
pidlist 'utility'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "utility Perf Agent analysis program %-9sRunning\n",$1}'
done
fi
if [ "$VMWARE" != "vmware" ]; then
pidlist 'midaemon'
if [ $? != 0 ]; then
for ip in $PIDLIST; do
id=`ps -p $ip -f | grep midaemon | awk '{printf "%d\n",$3}' `
parent_found=0
for j in $PIDLIST; do
if [ $j = $id ]; then
parent_found=1
break;
fi
done
if [ $parent_found = 0 ]; then
echo "($ip)"|awk '{ printf "midaemon Measurement Interface daemon %-9sRunning\n",$1}'
break
fi
done
else
ip=""
echo "$ip"|awk '{ printf "midaemon Measurement Interface daemon %-9sStopped\n",$1}'
fi
fi
pidlist 'ttd'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "ttd ARM registration daemon %-9sRunning\n",$1}'
done
else
ip=""
echo "$ip"|awk '{ printf "ttd ARM registration daemon %-9sStopped\n",$1}'
fi
if [ "$SYS" = "AIX" ]; then
pidlist 'lsdaemon'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "lsdaemon logical systems daemon %-9sRunning\n",$1}'
done
fi
fi
pidlist 'perfalarm'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "perfalarm Alarm generator %-9sRunning\n",$1}'
done
else
ip=""
[ -r /var/opt/perf/alarmdef ] && echo "$ip"|awk '{ printf "perfalarm Alarm generator %-9sStopped\n",$1}'
fi
pidlist 'perfd'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "perfd real time server %-9sRunning\n",$1}'
done
else
ip=""
IsLicAvailable "RTMA"
[ $? != 0 ] && echo "$ip"|awk '{ printf "perfd real time server %-9sStopped\n",$1}'
fi
pidlist 'dsilog'
if [ $? != 0 ]; then
for ip in $PIDLIST
do
echo "($ip)"|awk '{ printf "dsilog Perf Data Source Integration %-9sRunning\n",$1}'
done
fi
}
#==============================================================================
# DSI Actions
#==============================================================================
CheckDSI () {
# Print the current status of the DSI logging processes
mwa_pidlist '(^dsilog$)|(\/dsilog$)'
if [ $? != 0 ]; then
echo "Perf Agent DSI logging process status:"
echo " The following DSI logging processes are running:"
# Filter ps output for dsilog, NOT PRECEEDED by sh, ksh, csh etc
awk 'BEGIN {printf " %5s %s\n",\
"PID","LOGFILE SET & CLASS"} \
/dsilog/ { i = index( $0, "dsilog" )
j = index( $0, "sh" )
if ( j==0 || j>i ) { i = i+6
restofline = substr ( $0, i+1, length()-i )
printf " Running dsilog %5s %s\n",$pf,restofline}}
{next}' pf=$PIDFIELD $PAPSFILE
echo
fi
} # CheckDSI
#==============================================================================
# CODA Actions
#==============================================================================
MakeDir()
{
: ${1?"MakeDir: missing arg 1"}
mkdir -p $1
chmod 555 $1
chown $OV_OWNER $1
}
OVO_Version ()
{
OVO_VERSION=""
OVO_VMAJOR=""
# Find out if there is already an OVO7.x or an OVO8.x agent
if [ -f $OV_BIN_DIR/OpC/install/opcinfo ]
then
OVO_VERSION=`awk ' $1 == "OPC_INSTALLED_VERSION" { print $2 } ' $OV_BIN_DIR/OpC/install/opcinfo`
OVO_VMAJOR=`echo $OVO_VERSION | awk ' BEGIN {FS="."} {printf("%d",$2)}'`
fi
OVO_AGENT=" "
if [ -x "$OV_BIN_DIR/opcmona" ]; then
if [ -x "$OV_BIN_DIR/opcctla" ]; then
OVO_AGENT="OVO7"
else
OVO_AGENT="OVO8"
fi
fi
}
StartCoda ()
{
mustberoot
if [ "$OVPA_BOOT" != 1 ]; then
CODA_PROC_NAME="oacore"
pidlist $CODA_PROC_NAME
if [ $? != 0 ]; then # CODA_PROC_NAME is already running
$CODAUTIL -config >/dev/null 2>&1 &
echo " The Operations Agent Core daemon is already running."
return
else
if [ "x" != "x${OVO_NPU_CMD}" ]; then
# if ovpa-ovo commmon components are configured to run as non-root, then su to non-root and execute coda
echo "NOTE: OVO Agent is configured to run as (${OVPA_OV_SUDO_USER}). "
echo " Hence Perf Agent-OVO common daemons will run as (${OVPA_OV_SUDO_USER})"
eval ${OVO_NPU_CMD} \"$CODA_START >/dev/null 2>&1 \"
else
$CODA_START >/dev/null 2>&1
fi
echo " The oacore daemon has been started."
fi
echo " It will be fully operational in a few minutes."
echo
fi
} # StartCoda
StopCoda ()
{
echo " "
} # StopCoda
CheckCoda ()
{
# Print the current status of the BBC, control and coda
echo
echo " Perf Agent Server status:"
echo
if [ -n "$OVCONTRL" ]; then
pidlist $OVCONTRL
if [ $? != 0 ]; then
echo " Running $OVCONTRL " \
"(OV control component) pid $PIDLIST"
else
echo "WARNING: $OVCONTRL is not active ((OV control component)"
OOPS=1
fi
fi
pidlist $BBCSERV
if [ $? != 0 ]; then
echo " Running $BBCSERV " \
"($BBC communication broker) pid $PIDLIST"
else
echo "WARNING: $BBCSERV is not active ($BBC communication broker)"
OOPS=1
fi
pidlist 'oacore'
if [ $? != 0 ]; then
echo " Running oacore " \
" (Operations Agent Core) pid(s) $PIDLIST"
else
echo "WARNING: oacore is not active (oacore component)"
OOPS=1
fi
} # CheckCoda
printDataSources() {
pidlist 'oacore'
if [ $? != 0 ];then
$OV_BIN_DIR/ovcodautil -showds 2>/dev/null |awk '/NumDataSources/ { n=$3; \
if ( n > 0 ) { \
printf(" Configured DataSources(%d)\n",n);\
getline;\
printf(" %s\n",$0); \
for (i=2;i<=n;i++) \
{ getline; \
printf(" %s\n",$0); \
} \
printf("\n"); \
} \
}'
fi
} # printDataSources
#==============================================================================
# VERSION routines
#==============================================================================
p_what() {
# Platform-specific what function, Linux has no what command, this
# function handles one filename passed in arg1.
if [ "$SYS" != "LINUX" -a "$ARCH_NAME" != "i86pc" ]; then
what $1
elif [ -x $OVPA_BIN_DIR/ovwhat ]; then
$OVPA_BIN_DIR/ovwhat $1
else
key='@(#)'
echo $1:
strings $1 | grep "$key" | sed "s/$key/$TAB/"
fi
} # p_what
printwhat() {
# Looks for $DIR/files in arg list and prints what-strings:
for FILE in $@
do
if [ ! -f "$DIR/$FILE" ]; then
echo "WARNING: Expected file $DIR/$FILE does not exist"
OOPS=`expr $OOPS + 1`
else
p_what "$DIR/$FILE" | \
awk ' /libOvScopeAccess/ { if (length(ExclChoice)<=0) \
{
i = index( $0, "=*=" )
if ( i > 0 )
{
split ($0, s)
ExclChoice=sprintf (" %-10s %+9s %s %s", s[2], s[3], s[4], s[5])
}
}
next }
/\=\*\=/ { if (length(BestChoice)<=0) \
{ i = index( $0, "=*=" ) - 1
BestChoice = substr ( $0, 16, i-16 ) }
next }
/(MWA)|(OVPA)/ { if (length(FirstChoice)<=0) \
{ i = index( $0, $2 )
FirstChoice=substr( $0, i, length()-i+1) }
next }
/(700)|(800)/ { if (length(SecondChoice)<=0) \
{ i = index( $0, $2 )
SecondChoice=substr( $0 , i, length()-i+1) }
next }
/\=\*\*\=/ { if (length(BbcChoice)<=0) \
{
split ($0, s)
BbcChoice=sprintf (" %-10s %s %s %s", s[2], s[3], s[4], s[5])
}
next }
/(Hewlett)|(AT\&T)/ { if (length(ThirdChoice)<=0) \
{ i = index( $0, $2 )
ThirdChoice=substr( $0 , i, length()-i+1) }
next }
{ if (length(LastChoice)<=0) \
{ i = index( $0, $2 )
LastChoice=substr( $0 , i, length()-i+1) }
next}
END { if (length(ExclChoice)>0)
printf "%20s %s\n", fn, ExclChoice
else if (length(BestChoice)>0)
printf "%20s %s\n", fn, BestChoice
else if (length(FirstChoice)>0)
printf "%20s %s\n", fn, FirstChoice
else if (length(SecondChoice)>0)
printf "%20s %s\n", fn, SecondChoice
else if (length(ThirdChoice)>0)
printf "%20s %s\n", fn, ThirdChoice
else if (length(BbcChoice)>0)
printf "%20s %s\n", fn, BbcChoice
else if (length(LastChoice)>0)
printf "%20s %s\n", fn, LastChoice
else
printf "%20s\n", fn
}
' fn=$FILE -
fi
done
} # printwhat
printwhat_OvDirect ()
{
FILE="$1"
if [ ! -f $DIR/$FILE ]; then
echo "WARNING: Expected file $DIR/$FILE does not exist"
OOPS=`expr $OOPS + 1`
else
if [ "$SYS" != "LINUX" -a "$ARCH_NAME" != "i86pc" ]; then
whatstring="what"
elif [ "$SYS" = "SUN" -a "$ARCH_NAME" = "i86pc" ]; then
whatstring="strings"
else
whatstring="ovwhat"
fi
VER=`$whatstring $DIR/$FILE | grep "Ver" | cut -f2 -d":"`
FileName=`$whatstring $DIR/$FILE | grep "FileN" | cut -f2 -d":"`
OS=`$whatstring $DIR/$FILE | grep -w "OS" | cut -f2 -d":"`
if [ "$SYS" = "HP-UX" ]; then
OSV=`$whatstring $DIR/$FILE | grep OSV | cut -f2 -d":" | cut -f1 -d"."`
elif [ "$SYS" = "SUN" -a "$ARCH_NAME" = "i86pc" ]; then
OSV=`$whatstring $DIR/$FILE | grep "(#)OSV" | cut -f2 -d":" | cut -f1 -d"."`
else
OSV=`$whatstring $DIR/$FILE | grep OSV | cut -f2 -d":" | cut -f1 -d" "`
fi
BLD_DATE=`$whatstring $DIR/$FILE | grep CBID | cut -f2 -d":" | cut -b1-15`
BITS=`$whatstring $DIR/$FILE | grep Bits | cut -f2 -d":" | cut -f1 -d" "`
if [ "$BITS" = "64" ];then
if [ "$SYS" != "LINUX" ]; then
VERSION_STRING=" $FileName $VER ${BLD_DATE} $OS ${OSV}_64"
else
OSA=`$whatstring $DIR/$FILE | grep Arch | cut -f2 -d":"`
VERSION_STRING=" $FileName $VER ${BLD_DATE} $OS ${OSV}_${OSA}"
fi
else
if [ "$SYS" != "HP-UX" ]; then
VERSION_STRING=" $FileName $VER ${BLD_DATE} $OS $OSV+"
else
VERSION_STRING=" $FileName $VER ${BLD_DATE} $OS $OSV"
fi
fi
echo "$VERSION_STRING" | awk '{printf ("%20s %9s %s %s %s \n", $1, $2, $3, $4, $5) }'
fi
}
CheckVersion ()
{
# checks all version (whatstrings) for the component files of Perf Agent
echo
DIR=$OVPA_BIN_DIR
echo "Perf Agent executables in the directory $DIR"
printwhat $OVPA_BINLIST
NATIVE_LCORE=NO
if [ $SYS = "LINUX" ]; then
if [ `uname -r|cut -c1-3` = "2.6" -o `uname -r|cut -c1` -ge 3 ] && \
[ `uname -m` = "x86_64" -o `uname -m` = "ia64" -o `uname -m` = "ppc64" ] && \
[ -f /opt/perf/lib64/libnums.so ]
then
NATIVE_LCORE=YES
fi
elif [ $SYS = "AIX" -a "$INSTALLED_BITS" = "64" ]; then
NATIVE_LCORE=YES
fi
if [ "${NATIVE_LCORE}" = "YES" ]; then
echo
DIR=$OVPA_LIB64_DIR
else
echo
DIR=$OVPA_LIB_DIR
fi
echo "Perf Agent libraries in the directory $DIR"
if [ $SYS = "HP-UX" ]; then
printwhat libarm$LIBEXT
printwhat libnums$LIBEXT
printwhat libscope$LIBEXT
printwhat libarmNOP$LIBEXT
printwhat liblicense$LIBEXT
printwhat_OvDirect $OVPA_LIBLIST_CODA
else
printwhat $OVPA_LIBLIST
printwhat_OvDirect $OVPA_LIBLIST_CODA
if [ "${NATIVE_LCORE}" = "YES" ]; then
if [ `uname -p` = "x86_64" -o "$INSTALLED_BITS" = "64" ]; then
echo
echo "Perf Agent 32-bit arm libraries in the directory $OVPA_LIB_DIR"
DIR=$OVPA_LIB_DIR
printwhat libarm$LIBEXT
printwhat libarmNOP$LIBEXT
if [ "$INSTALLED_BITS" = "64" ]; then
printwhat libarmns$LIBEXT
fi
fi
elif [ `uname -p` = "x86_64" ]; then
echo
echo "Perf Agent 64-bit arm libraries in the directory $OVPA_LIB64_DIR"
DIR=$OVPA_LIB64_DIR
printwhat libarm$LIBEXT
fi
fi
echo
if [ "${NATIVE_LCORE}" = "YES" ]; then
DIR=$OVPA_METDESC64_DIR
else
DIR=$OVPA_METDESC_DIR
fi
echo "Perf Agent metric description file in the directory $DIR"
printwhat metdesc
echo
if [ "${NATIVE_LCORE}" = "YES" ]; then
DIR=$OV_LIB64_DIR
else
DIR=$OV_LIB_DIR
fi
echo "Perf Agent libraries in the directory $DIR"
printwhat $OV_LIBLIST
echo
if [ "$OOPS" = "0" ]; then
echo "All critical Perf Agent files are accessible"
else
echo "WARNING: $OOPS Perf Agent files were not found or inaccessible"
fi
echo
} # CheckVersion
NiceOVPAExit ()
{
# NiceOVPAExit deletes OVPA_RUN
# This function can be used as a wrapper for any other on-exit tidying.
# if nodelete is supplied as $2, we do not delete the OVPA_RUN file
exitstatus=$1
if [ "$2" != "nodelete" ]; then
if [ -w $OVPA_DATA_DIR/OVPA_RUN ]; then
rm $OVPA_RUN_FILE
fi
fi
PurgePAPSFILE
exit $exitstatus
} # NiceOVPAExit
SUOvpaStart ()
{
mustberoot
# SUOvpaStart creates OVPA_RUN
# It is called from start stop and restart functions in main
# (and not every time ovpa is started)
# check for the existance of datafiles directory.
# If not exist create that directory.
if [ ! -d $OVPA_DATA_DIR ];then
mkdir -p $OVPA_DATA_DIR
fi
# At this time we know, the user is superuser, we need to check if another
# ovpa is run in a superuser modus
if [ -f $OVPA_RUN_FILE ]; then
# the OVPA_RUN file exists... Let's check for a ovpa process running
# There could be a problem with this if the ovpa script is renamed,
# also - if the user has a process containing ovpa, the OVPA_RUN will have
# to be deleted manually - no way around this)
odg=`$PS | grep ovpa | grep -v 'grep' | grep -v $$ | wc -l`
if [ $odg -ge 1 ]; then
echo "ERROR: Only one superuser (root) type of ovpa command can be"
echo " run at the same time. If this is the only instance, please"
echo " delete $OVPA_RUN_FILE"
PurgePAPSFILE
NiceOVPAExit 1 nodelete
fi
fi
# create $OVPA_DATA_DIR/OVPA_RUN
echo "ovpa script running in a root-required mode." > $OVPA_RUN_FILE
} # SUOvpaStart
#-------- Process the command ---------------#
execute ()
{
#---------------------------------------------- restart_collection Command
if [ "$FUNCTION" = "restart_collection" ]; then
Restart_Collection
fi
#----------------------------------------------- status perf Command
if [ "$SUBSYS" = "perf" ]; then
if [ "$FUNCTION" = "status" ]; then
CheckPerf
else
printusage
PurgePAPSFILE
NiceOVPAExit 1 nodelete
fi
fi
#----------------------------------------------- STATUS Command
if [ "$FUNCTION" = "status" ]; then
if [ "$SUBSYS" = "scope" ]; then
CheckScope
fi
if [ "$SUBSYS" = "coda" ]; then
CheckCoda
printDataSources
fi
if [ "$SUBSYS" = "server" ]; then
CheckCoda
printDataSources
CheckAlarms
CheckDSI
CheckVIdaemon
fi
if [ "$SUBSYS" = "alarm" ]; then
CheckAlarms
fi
if [ "$SUBSYS" = "all" ]; then
CheckScope
CheckCoda
printDataSources
CheckAlarms
CheckDSI
fi
fi
#-----------------------------------------------VERSION Command
if [ "$FUNCTION" = "version" ]; then
CheckVersion
fi
#-----------------------------------------------START Command
if [ "$FUNCTION" = "start" ]; then
SUOvpaStart
if [ "$SUBSYS" = "scope" ]; then
StartScope
fi
if [ "$SUBSYS" = "oacore" ]; then
StartScope
fi
if [ "$SUBSYS" = "coda" ]; then
StartCoda
fi
if [ "$SUBSYS" = "server" ]; then
StartCoda
StartAlarms
fi
if [ "$SUBSYS" = "alarm" ]; then
StartAlarms
fi
if [ "$SUBSYS" = "all" ]; then
StartScope
StartCoda
StartAlarms
fi
PurgePAPSFILE
if [ $startup_exit_status -ne 0 ]
then
NiceOVPAExit 1
fi
NiceOVPAExit 0
fi
#-----------------------------------------------STOP Command
if [ "$FUNCTION" = "stop" ]; then
SUOvpaStart
if [ "$SUBSYS" = "scope" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
fi
if [ "$SUBSYS" = "oacore" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
fi
if [ "$SUBSYS" = "coda" ]; then
CODA_ACTION="stop"
StopCoda
fi
if [ "$SUBSYS" = "server" ]; then
StopAlarms
StopCoda
fi
if [ "$SUBSYS" = "alarm" ]; then
StopAlarms
fi
if [ "$SUBSYS" = "all" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
StopAlarms
StopCoda
fi
PurgePAPSFILE
NiceOVPAExit 0
fi
#-----------------------------------------------RESTART Command
if [ "$FUNCTION" = "restart" ]; then
SUOvpaStart
if [ "$SUBSYS" = "scope" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
getnewpidlist
StartScope
fi
if [ "$SUBSYS" = "oacore" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
getnewpidlist
StartScope
fi
if [ "$SUBSYS" = "coda" ]; then
CODA_ACTION="stop"
StopCoda
StartCoda
fi
if [ "$SUBSYS" = "alarm" ]; then
RestartAlarms
fi
if [ "$SUBSYS" = "server" ]; then
getnewpidlist
StopAlarms
CODA_ACTION="stop"
StopCoda
StartCoda
StartAlarms
fi
if [ "$SUBSYS" = "all" ]; then
pidlist 'oacore'
if [ $? != 0 ]; then
StopScope
fi
StopAlarms
StopCoda
getnewpidlist
StartScope
StartCoda
StartAlarms
fi
if [ $startup_exit_status -ne 0 ]
then
NiceOVPAExit 1
fi
NiceOVPAExit 0
fi
#-----------------------------------------------DEMO Command
if [ "$FUNCTION" = "demo" ]; then
if [ -x $OVPA_BIN_DIR/ovpademo ]; then
$OVPA_BIN_DIR/ovpademo
else
echo "Unable to execute the $OVPA_BIN_DIR/ovpademo script"
fi
fi
PurgePAPSFILE
NiceOVPAExit $OOPS nodelete
}
#==============================================================================
# MAIN
#==============================================================================
if [ -r /var/opt/perf/vppa.env ]; then
. /var/opt/perf/vppa.env
fi
if [ "`uname -s`" = "AIX" ]; then
if [ -f /usr/lpp/perf/lib64/libnums.a ]; then
INSTALLED_BITS=64
else
INSTALLED_BITS=32
fi
fi
# Added this for Sun so we can find utilities like "what".
# If SUNWsprot package not installed (and /usr/ccs/bin/what doesn't exist),
# /opt/perf/bin/what is used instead.
cd /
PATH=$PATH:/usr/bin:/bin:/usr/ucb:/usr/sbin:/usr/ccs/bin
INTERACTIVE=`tty -s;echo $?`; export INTERACTIVE
# The colums = 160 is for large ps commands that exceed 80 columns.
COLUMNS=1024; export COLUMNS
#-----------------------------------------------Parse Input Parameters
FUNCTION="start"
SUBSYS="all"
FAST=" "
CODA_ACTION=" "
while [ $# -gt 0 ]
do
if [ "$1" = "?" \
-o "$1" = "-?" ]; then
printusage
PurgePAPSFILE
NiceOVPAExit 0 nodelete
fi
if [ "$1" = "status" -o "$1" = "-status" \
-o "$1" = "start" -o "$1" = "-start" \
-o "$1" = "stop" -o "$1" = "-stop" \
-o "$1" = "restart" -o "$1" = "-restart" \
-o "$1" = "version" -o "$1" = "-version" \
-o "$1" = "versions" -o "$1" = "-versions" \
-o "$1" = "demo" -o "$1" = "-demo" ]; then
FUNCTION=`echo $1 | sed 's/-//'`
elif [ "$1" = "scope" \
-o "$1" = "oacore"\
-o "$1" = "coda" \
-o "$1" = "server" \
-o "$1" = "servers" \
-o "$1" = "alarm" \
-o "$1" = "alarms" \
-o "$1" = "perf" \
-o "$1" = "all" ]; then
SUBSYS=$1
elif [ "$1" = "-ps" ]; then
shift
P_PSFILE="$1"
elif [ "$1" = "-midaemon" ]; then
while [ $# -gt 0 ]
do
shift
MIPARMS="$MIPARMS $1"
done
else
echo
echo "Invalid parameter \"$1\" "
printusage
PurgePAPSFILE
NiceOVPAExit 1 nodelete
fi
if [ "$#" -gt 0 ]; then
shift
fi
if [ "$#" -eq 1 -a "$1" = "fast" ]; then
if [ "$FUNCTION" = "stop" -o "$FUNCTION" = "start" ]; then
FAST=$1
shift
fi
fi
done
# Change plurals back to standard form
if [ "$FUNCTION" = "versions" ]; then
FUNCTION="version"
fi
if [ "$SUBSYS" = "servers" ]; then
SUBSYS="server"
fi
if [ "$SUBSYS" = "alarms" ]; then
SUBSYS="alarm"
fi
# note this sets must be done after the option parsing above because sh
# as opposed to ksh does not preserve args in functions:
sets
PATH=$PATH:$OV_BIN_DIR/OpC:$OVPA_BIN_DIR:$M10ICODA_DIR
OVPA_RUN_FILE="$OVPA_DATA_DIR/OVPA_RUN"
startup_exit_status=0
if [ "$SYS" = "LINUX" ]; then
HP_PETC_VERSION=`rpm -q --qf "%{VERSION}" HPOvPetc | cut -f2 -d'.'`
fi
# Setting Coda Variables
if [ "$ARCH_NAME" = "x86_64" -a "$SYS" = "LINUX" -a "$HP_PETC_VERSION" = "50" ]; then
CODAUTIL="$OV_BIN_DIR/codautil"
BBC="BBC2"
BBCSERV="llbserver"
M10ICODA_DIR="/opt/OV/bin"
if [ -f $OV_BIN_DIR/OpC/opcagt ]; then
CODA_START="$OV_BIN_DIR/ovc -start oacore"
CODA_STOP="$OV_BIN_DIR/ovc -stop oacore"
OVCONTRL="opcctla"
else
CODA_START="$OV_BIN_DIR/codautil -start"
CODA_STOP="$OV_BIN_DIR/codautil -stop"
OVCONTRL=""
fi
else
CODAUTIL="$OV_BIN_DIR/ovcodautil"
CODA_START="$OV_BIN_DIR/ovc -start oacore"
CODA_STOP="$OV_BIN_DIR/ovc -stop oacore"
BBC="BBC5"
BBCSERV="ovbbccb"
OVCONTRL="ovcd"
fi
execute
# Delete ovpaps$$ if leftover:
PurgePAPSFILE