#!/bin/ksh # set -x # # Filename: ITO_Status.ksh # # Created by: AE Whale - aewhale@ABS-CompTech.com # ABS Computer Technology, Inc. # # Copyright (c) 2000 - All rights reserved # # This utility will verify that the opcctla Daemon is communicating # properly, and that all of the associated daemons as well as communications # to the Management Server are working properly. # # Command: ITO_Status.ksh HTYPE=$(uname -s) PLIST=/tmp/ITO_plist.$$ OPC_LIST=/tmp/OPC_list.$$ OPC_NUMS=/tmp/OPC_nums.$$ PGM=$0 let bad_num=0 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 -fu root > $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 ps -fu root > $PLIST break;; SunOS) # Software installed on a SunOS Server export OPC_BIN=/opt/OV/bin/OpC export OPCMSG=/opt/OV/bin/OpC/opcmsg ps -fu root > $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 -fu root > $PLIST break;; esac $OPC_BIN/opcctla -status > $OPC_LIST if [ $? -gt 0 ] then let bad_num=$bad_num+1 fi num_bad=$(cat $OPC_LIST | grep -c -E "isn't running| not running") let bad_num=$bad_num+$num_bad Kill_OPCAGT () { # cat $OPC_LIST # echo Need to restart the ITO Agent NumBad = $bad_num cat $OPC_LIST | grep "is running" | grep -v OpC30 | cut -f2 -d'(' | awk '{print $1}' | sed s/\)//g > $OPC_NUMS if [ -n $OPC_NUMS ] then $OPC_BIN/opcctla -kill for cnum in `cat ${OPC_NUMS}` do kill $cnum > /dev/null 2>&1 done for cnum in `cat $OPC_NUMS` do kill -9 $cnum > /dev/null 2>&1 done fi } $OPC_BIN/opcmsg appl=ito_status obj=opcagt msg_t=test msg_g=OpC if [ $? -gt 0 ] then let bad_num=$bad_num+1 fi if [ $bad_num -gt 0 ] then Kill_OPCAGT $OPC_BIN/opcctla -start $OPC_BIN/opcmsg sev=minor appl=ito_status obj=opcagt msg_t="Restarted opcagt" msg_g=OpC fi rm -f $PLIST $OPC_LIST $OPC_NUMS exit 0