HP Serviceguard Developer's Toolbox Version B.12.00.00 For HP-UX and Linux

echo "$(date '+%b %e %T') - Node \"$(hostname)\": Starting the monitoring process"
while :; do
# Maintenance code. This script will check whether the debug file
# exists and only then Package gets into maintenance mode. Monitoring
# is stopped completely at this moment.
if [ -z "$MAINTENANCE_FILE" ] || [ ! -f "$MAINTENANCE_FILE" ]; then
if [ $maintenance -eq 1 ]; then
sg_log 0 "Starting monitoring again after maintenance"
maintenance=0
fi
# Invoke monitor function
if the maintenance file does not exist if [ ! -f "$MAINTENANCE_FILE" ]
then
case $APP_TKIT_MONITORING_TYPE in
pid_file | PID_FILE)
pid_file $APP_TKIT_MONITORING_ELEMENT
;;
process_monitor | PROCESS_MONITOR)
process_monitor $APP_TKIT_MONITORING_ELEMENT
;;
port_monitor | PORT_MONITOR)
port_monitor $APP_TKIT_MONITOR_ELEMENT
;;
*)
echo "Invalid APP_TKIT_MONITORING_TYPE :
$APP_TKIT_MONITORING_TYPE option specified !"
exit 1
;;
esac
fi
exit_status=$?
if [[ $exit_status != 0 ]]
then
sg_log 0 "Exiting Toolkit Monitoring because one of the key process has failed."
echo "Exiting Toolkit Monitoring because one of the key process has failed."
#exit 1
return 1
fi
# TOOLKIT IN MAINTENANCE MODE
else
if [ $maintenance -eq 0 ]; then
sg_log 0 "Toolkit pausing monitoring and entering maintenance mode"
maintenance=1
fi
fi
sleep ${APP_TKIT_MONITOR_INTERVAL}
done
}
#############################################################
#
# PID FILE
#
############################################################
function pid_file
{
PID_LIST=$*
if [ -z "$APP_APP_SERVER_PROC" ]; then
sg_log 0 "ERROR: APP_APP_SERVER_PROC is not defined.";
sg_log 0 "ERROR: Validation Failed. Improper parameters in Toolkit Configuration file"
return 1;
fi
for i in ${PID_LIST[@]}
do
id=`cat $i 2> /dev/null`
exit_code=$?
if [[ $exit_code != 0 ]]; then
sg_log 0 "ERROR: $i file not found. Halting the monitor script."
return 1;
fi
if [[ $ENVIRONMENT = "HP-UX" ]]; then
p_name=`ps -p $id | awk '{ print $4}' | grep "^$APP_APP_SERVER_PROC$"`
if [ -z "$p_name" ]; then
sg_log 0 "ERROR: The process $id is not running. Halting the monitor script."
return 1;
else
continue;
fi
else
grep $APP_APP_SERVER_PROC /proc/$id/stat >/dev/null
if [ $? -ne 0 ]; then
sg_log 0 "ERROR: The process $id is not running. Halting the monitor script."
return 1;
31