## Monitor Lawson Compile Queue ## ## ## Based upon an original script by J. David Schronce ## http://www.schronce.net/lawson ## Modified by ## J. Cole Hitachi Consulting 2004 ## ## Original Intent is preserved. Differences from original are ## o Use text file for queries rather than repeatedly running qstatus. ## - makes script run faster when performing product-line compiles ## o Made Product line parameter optional ## - defaults to the first productline it finds in the queue ## o Added parameter to configure refresh wait time ## - allows slower update for product-line compiles ## o Added final error listing at completion of Queue processing ## o Added count of "waiting" programs in queue to information output ## o Increased default wait time from 3 to 5 seconds ## o Changed source layout ## #################################################################### process_args() { while getopts ?xn:p: opt do case $opt in n) WAITTIME="$OPTARG" export WAITTIME ;; p) PRODLINE="$OPTARG" export PRODLINE ;; x) DEBUG="set -x" $DEBUG ;; ?) do_usage ;; esac done $DEBUG set +u if [ -z "$WAITTIME" ] then WAITTIME=5 fi if [ -z "$PRODLINE" ] then # No Product line given; try to get a default one from qstatus PRODLINE=`qstatus|grep "On local"|head -1|cut -c40-|cut -d ' ' -f1` if [ -d $LAWDIR/$PRODLINE ] ; then echo defaulting to $PRODLINE else do_usage fi fi } do_usage() { USAGE="USAGE:\t$0 [-p productline] [-n #]\n\n\tWhere n = seconds to wait before refresh\n\n" echo "\n\n$USAGE\n" exit 1 } display_stats() { $DEBUG # Display Information clear echo; # Display Header from Qstatus (time date etc.) head -1 ~/qs.txt echo "======================================================================"; # Generate list of err files for reference ls -l ??src/*.err >~/errs.txt 2>/dev/null cat ~/errs.txt print "Total number of error files \c"; wc -l ~/errs.txt | awk '{print $1}' echo; echo Currently Compiling: grep "On local" ~/qs.txt echo; echo; echo There are `grep -c "Waiting" ~/qs.txt` Jobs Waiting to compile. echo; echo; echo "Last job(s) entered into the QUEUE." tail -2 ~/qs.txt } ### Start of Program process_args $@ $DEBUG cd $LAWDIR/$PRODLINE while true do qstatus > ~/qs.txt display_stats rm -f ~/qs.txt sleep $WAITTIME if [ `qstatus | grep "On local" | wc -l` -eq 0 ];then ls -l ??src/*.err >~/errs.txt 2>/dev/null date cat ~/errs.txt rm -f ~/errs.txt exit 0 fi done