#!/bin/ksh # set -x # # Filename: ABS_Monitor.sh # # Created by: AE Whale - aewhale@ABS-CompTech.com May 10, 2000 # ABS Computer Technology, Inc. # # Copyright (c) 2000 - All rights reserved # # The purpose of this script is to validate and report the status of # various processes running on the Server. If a process is running then the # monitor performs no action. When the process is not in the Process Table, # this script will report the failure back to the ITO Message Server. # # Command: ABS_Monitor.sh ..... HTYPE=$(uname -s) PLIST=/tmp/ABS_List.$$ PGM=$0 MNAME=$1 case $HTYPE in HP-UX) # Software installed on an HP Server export OPC_BIN=/opt/OV/bin/OpC export OPCMSG=/opt/OV/bin/OpC/opcmsg ps -ef | grep -v $0 > $PLIST break;; Linux) # Software installed on a Linux Server ps -ax | grep -v $0 > $PLIST export OPC_BIN=/opt/OV/bin/OpC export OPCMSG=/opt/OV/bin/OpC/opcmsg break;; SunOS) # Software installed on a SunOS Server export OPC_BIN=/opt/OV/bin/OpC export OPCMSG=/opt/OV/bin/OpC/opcmsg ps -ef| grep -v $0 > $PLIST break;; SCO_SV) # Software installed on a SCO Server export OPC_BIN=/opt/OV/bin/OpC export OPCMSG=/opt/OV/bin/OpC/opcmsg ps -ef | grep -v $0 > $PLIST break;; esac shift for pname in $* do nprocs=$(grep -c $pname $PLIST) $OPC_BIN/opcmon $MNAME=$nprocs if [ $nprocs -eq 0 ] then msg1="$pname process name was not found in the list" $OPCMSG application="ProcMonitor" obj=$pname severity=critical msg_t="$msg1" msg_g=OS if [ $? -ne 0 ] then mail -s "Restarting ITO Agents on $(hostname)" ito_adm@nochost1.cqtel.com $OPC_BIN/opcagt -start if [ $? -ne 0 ] then mail -s "ITO Agent restart on $(hostname) FAILED" ito_critical@nochost1.cqtel.com rm -f $PLIST exit 1 fi $OPCMSG application="ProcMonitor" obj=$pname severity=critical msg_t="$msg1" msg_g=OS fi fi done rm -f $PLIST exit 0