Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KSH script to ignore reorg and update stats

Status
Not open for further replies.

markcurtis

Technical User
Aug 2, 2001
2
US
Hi all,

I need to do the following to amend a ksh script.
1. The message it displays says contact PSIG and not FNX.
2. It detects on program and ignores reorg and update stats.

Part one id complete as you can see below but where and how do I get part 2 to work in the below script.

Many thanks
Mark

#!/bin/ksh
ENVNAME=$1
. /fnx/.fnxsecurity
PROGNAME=$( basename $0 )
TMPFILE1=/tmp/${PROGNAME}.1.$$
TMPFILE2=/tmp/${PROGNAME}.2.$$
MSGFILE=/tmp/${PROGNAME}.3.$$
LOCKLIST=/tmp/${PROGNAME}.lockspids
LASTLOCKLIST=/tmp/${PROGNAME}.lockspids.last

if [[ ! -f $LASTLOCKLIST ]] ; then
echo > $LASTLOCKLIST
fi

if (( $( ps -ef | grep sylimrecomp | grep $ENVNAME | wc -l ) == 0 )) ; then
SEVERITY=$MAXEERRSTR
else
SEVERITY=$MAXEINFSTR
fi

echo >$LOCKLIST

isql -U${SYBOPER} -P${SYBPASS} <<-EOT >${TMPFILE1}
select distinct &quot;XXX&quot;, blocked from master..sysprocesses where blocked != 0 and dbid = db_id(&quot;${DBNAME}&quot;)
go
EOT

#echo &quot; XXX 1916&quot; >${TMPFILE1}

for BLOCKINGSPID in $( cat ${TMPFILE1} | nawk '/XXX/{print $2 }' ) ; do
isql -U${SYBOPER} -P${SYBPASS} -S${DSQUERY} <<-EOT >${TMPFILE2}
select &quot;XXX&quot;, hostprocess, program_name from master..sysprocesses where spid=${BLOCKINGSPID}
go
EOT
BLOCKINGSYBEXE=$( cat ${TMPFILE2} | nawk '/XXX/{print $3}' ) # If the Unix process is gone then this may be useful
BLOCKINGPID=$( cat ${TMPFILE2} | nawk '/XXX/{print $2}' )
echo ${BLOCKINGPID}>>$LOCKLIST
grep &quot;${BLOCKINGPID}&quot; $LASTLOCKLIST >/dev/null 2>&1
if (( $? == 0 )) ; then
# The program with PID $BLOCKINGPID was causing locks last time the script was run too so alert on the long lasting lock
ps -eo comm,pid | grep ${BLOCKINGPID} | nawk '{print $1}' >${TMPFILE2}
TMPVAR=$( cat $TMPFILE2 )
BLOCKINGEXE=$( basename $TMPVAR )
/usr/ucb/ps -aux | grep ${BLOCKINGPID} > /fnx/${PROGNAME}.pid${BLOCKINGPID}.truss.procinfo
# nohup truss -fea -d -D -vall -o /fnx/${PROGNAME}.pid${BLOCKINGPID}.truss -p ${BLOCKINGPID} &
# Get the Sybase info which will help if the Unix proc has disappeared
isql -U${SYBOPER} -P${SYBPASS} -S${DSQUERY} <<-EOT >/fnx/${PROGNAME}.pid${BLOCKINGPID}.sybinfo
select * from master..sysprocesses where spid=${BLOCKINGSPID}
go
EOT
if [[ &quot;${BLOCKINGEXE}&quot; == &quot;.&quot; ]] ; then
echo $SEVERITY$ Process ${BLOCKINGPID} died but left Sybase spid ${BLOCKINGSPID} named \&quot;$BLOCKINGSYBEXE\&quot; on $MCNAME blocking environment $ENVNAME at $( date ) - inform PSIG >$MSGFILE
else
echo $SEVERITY Process ${BLOCKINGPID} named $BLOCKINGEXE on $MCNAME blocking environment $ENVNAME at $( date ) - inform PSIG >$MSGFILE
fi
logger -p user.notice -f$MSGFILE
cat $MSGFILE | tee -a /fnx/${PROGNAME}.log
if [[ &quot;${BLOCKINGEXE}&quot; == &quot;fxtrdent&quot; || &quot;${BLOCKINGSYBEXE}&quot; == &quot;fxtrdent&quot; ]] ; then
echo $SEVERITY$ Killing Process ${BLOCKINGPID} at $( date ) >$MSGFILE
logger -p user.notice -f$MSGFILE
cat $MSGFILE | tee -a /fnx/${PROGNAME}.log
kill -9 ${BLOCKINGPID}
fi
fi
done
mv $LOCKLIST $LASTLOCKLIST
rm $TMPFILE1 $TMPFILE2 $MSGFILE >/dev/null 2>&1

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top