#! /bin/csh -f # # report the ALS ring current # # set Iring = `blmotor.com Beam Current | awk '$NF~/[0-9]/{print $NF}'` set hhmistat set test = `echo $Iring | awk '{print ($1+0==0)}'` if($test) then # ping -w 1 -c 1 www-als.lbl.gov >& /dev/null nmap -PT -p 80 www-als.lbl.gov |& grep "1 host up" >& /dev/null if(! $status) then set test = `echo "GET /als/als_ops/status.html" | sock_exchange.tcl www-als.lbl.gov | awk 'BEGIN{RS="[<>]"} /mA/{print $1+0; exit}'` if("$test" != "") set Iring = $test endif endif if("$Iring" == "") set Iring = "unknown" echo -n "$Iring mA " set beamline = `beamline.com` if("$beamline" =~ 50*) then echo "" exit endif set flux = `blmotor.com Imono In |& awk '/unknown value/{print "down";exit} {printf "%d", $NF+0} /got beam/{print 999}' | tail -1` if("$flux" == "down") then echo "frontend down" exit 9 endif if("$flux" == "") set flux = 0 if($flux > 50) then echo -n "light available " set GOOD else set test = `echo $Iring 5 | awk '{print ($1<$2)}'` if ($test) then echo -n "and down " else set otherlight_count = 0 foreach itr ( 1 ) # check to see if the ALS has beam # echo "GET /als/status/alsgeneral.gif" |\ # sock_exchange.tcl www-als.lbl.gov |\ wget -o /dev/null -O - http://www.als.lbl.gov/als/status/alsgeneral.gif |\ tee /tmp/${USER}/als_status.gif |\ convert -depth 8 -crop 113x63+521+113 - RGB:- |\ od -w3 -v -t u1 |\ awk '! / 0 0 0$/{r+=$2;g+=$3;b+=$4;++n}\ END{print r/n,g/n,b/n}' |\ awk '$2>$1{print "green";exit} $1>$2{print "red";exit} {print "unknown"}' |\ cat >! /tmp/tmpstatus$$ set ringstatus = `cat /tmp/tmpstatus$$` rm -f /tmp/tmpstatus$$ >& /dev/null # check to see if we are the only one foreach otherline ( 821 831 ) setenv beamline $otherline set otherflux = `blmotor.com Imono In | awk '$NF!~/^[0-9]/{print "down"} {printf "%d", $NF+0} /got beam/{print 999}' | tail -1` if("$otherflux" == "") set otherflux = 0 if("$otherflux" > 100) then set HHMI_HAS_LIGHT set hhmistat = "$otherline has light" endif end if("$ringstatus" == "green" || $?HHMI_HAS_LIGHT) then # looks bad, but let's try 3 times to be sure @ otherlight_count = ( $otherlight_count + 1 ) sleep 2 else # nobody else has light either break endif end if($otherlight_count > 0) then echo -n "and offline $hhmistat " set BAD else echo -n "and filling " endif unsetenv beamline endif set BAD endif set Izero = `blmotor.com Izero | awk '{printf "%d", $NF*1000} /got beam/{print 999}' | tail -1` if("$flux" == "") set flux = 0 if($Izero > 50) then echo -n "hutch is hot " else echo -n "hutch is dark " endif echo "" if ($?BAD) exit 9 exit