0470873ed50d2c9f885dbc97bf23c7e474a66cba
rhead
  Wed Jun 5 22:16:06 2013 -0700
Fixed problem with only the first 100 blat servers being tested (the outer while loop was setting list2 to nothing but then requiring it to not be empty in order to continue). Also changed to generate output only when errors are found and got rid of email to individuals so that it can be controlled more easily from the qateam crontab. Finally, added the PID to the filename and an instruction for cleanup on interruption. refs #10796
diff --git src/utils/qa/blatPing.csh src/utils/qa/blatPing.csh
index 9743519..69dfb41 100755
--- src/utils/qa/blatPing.csh
+++ src/utils/qa/blatPing.csh
@@ -1,52 +1,50 @@
 #!/bin/tcsh
 source `which qaConfig.csh`
 
+onintr cleanup
+
 cd ${HOME}
 
 if ( "$HOST" != "hgwdev" ) then
     echo "error: you must run this script on dev!"
     exit 1
 endif
 
 hgsql -h $sqlrr hgcentral -B -N -e "SELECT db, host, port FROM blatServers \
-  ORDER BY db, host, port" > blatList
+  ORDER BY db, host, port" > blatList$$
 
 #Need to do it in two steps so list is not too long giving word too long error.
-set list = (`head -100 blatList`)
-set list2 = (`tail --lines=+101 blatList`)
+set list = (`head -100 blatList$$`)
+set list2 = (`tail --lines=+101 blatList$$`)
 
 # next line just for testing:
 #set list = (xx1 blat13 17779 xx2 blat14 17779 xx3 blat12 17779)
 set problems = ()
-while ( "$list2" != "" && "$list" != "" )
+while ( "$list" != "" )
     while ( "$list" != "" )
 	set db = $list[1]
 	shift list
 	set host = $list[1]
 	shift list
 	set port = $list[1]
 	shift list
 	#-- use to remove monotonous long running blat failures:
 	#if ("$db" != "rn2") then
-	 echo "$db $host $port"
 	 gfServer status $host $port > /dev/null
 	 set err = $status
 	 if ( $err ) then
 	    echo "error $err on ${db} ${host}:${port}"
 	    set problems = ($problems "${db} ${host}:${port}\n")
 	 endif
 	#endif
     end
     set list = ( $list2 )
     set list2 = ()
 end
-echo
-echo "Summary:"
 if ( "$problems" != "") then
+    echo "Summary:"
     echo "problems:"
     echo "$problems"
-    echo "$problems" | mail -s "BLAT ping failures." galt kuhn donnak ann rhead  # DEBUG RESTORE
-else
-    echo "blat ping all ok."
-    rm -f blatList
 endif
+cleanup:
+    rm -f blatList$$
