markcurtis
Technical User
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 "XXX", blocked from master..sysprocesses where blocked != 0 and dbid = db_id("${DBNAME}"
go
EOT
#echo " XXX 1916" >${TMPFILE1}
for BLOCKINGSPID in $( cat ${TMPFILE1} | nawk '/XXX/{print $2 }' ) ; do
isql -U${SYBOPER} -P${SYBPASS} -S${DSQUERY} <<-EOT >${TMPFILE2}
select "XXX", 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 "${BLOCKINGPID}" $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 [[ "${BLOCKINGEXE}" == "." ]] ; then
echo $SEVERITY$ Process ${BLOCKINGPID} died but left Sybase spid ${BLOCKINGSPID} named \"$BLOCKINGSYBEXE\" 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 [[ "${BLOCKINGEXE}" == "fxtrdent" || "${BLOCKINGSYBEXE}" == "fxtrdent" ]] ; 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
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 "XXX", blocked from master..sysprocesses where blocked != 0 and dbid = db_id("${DBNAME}"
go
EOT
#echo " XXX 1916" >${TMPFILE1}
for BLOCKINGSPID in $( cat ${TMPFILE1} | nawk '/XXX/{print $2 }' ) ; do
isql -U${SYBOPER} -P${SYBPASS} -S${DSQUERY} <<-EOT >${TMPFILE2}
select "XXX", 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 "${BLOCKINGPID}" $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 [[ "${BLOCKINGEXE}" == "." ]] ; then
echo $SEVERITY$ Process ${BLOCKINGPID} died but left Sybase spid ${BLOCKINGSPID} named \"$BLOCKINGSYBEXE\" 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 [[ "${BLOCKINGEXE}" == "fxtrdent" || "${BLOCKINGSYBEXE}" == "fxtrdent" ]] ; 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