Catch session waiting locks

Recently we have low performance in a informix instance and think the main trouble is some store procedures that have some lock waits. This script will help you to catch those sessions:

_ERRLOG=error.log
_OUTLOG=output.log
_TMPTMP=ivan.txt
while true 
do
 dbaccess sysmaster - ${_ERRLOG}>> 2>&1 <0
EOF
  for i in `cut  -f 1 -d'|' ${_TMPTMP}`
  do
    date |tee -a ${_OUTLOG}
    onstat -g ses ${i} |tee -a  ${_OUTLOG}
  done
  rm ${_TMPTMP}
  sleep 1
done