Changeset 18421
- Timestamp:
- 01/27/16 21:49:21 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Monitoring/CheckSwiftSchedule.sh
r18420 r18421 2 2 3 3 4 source `dirname $0`/../Sourcefile.sh 5 printprocesslog "INFO starting $0" 6 7 # list of sources 4 8 sources=( "Mrk 421" "Mkn 421" "1959" "V404" "0323" "Crab" "CRAB" "Mrk 501" "Mkn 501" ) 5 9 6 dates=(`date +"%Y-%m-%d" --date="-12hour"` `date +%Y-%m-%d --date="+12hour"`)7 10 8 date2=`echo ${dates[0]} | sed -e 's/-/\//g'` 9 schedulepath=/home/factwww/scheduling/$date2 10 schedulefile=$schedulepath/swift.schedule 11 schedulefile2=$schedulepath/swift.schedule.formated 12 schedulefile3=$schedulepath/swift.schedule.txt 11 # get dates 12 if [ "$certaindate" != "" ] 13 then 14 getdates $certaindate 15 else 16 if [ "$1" = "" ] 17 then 18 # get next 3 night 19 getdates +3 20 else 21 getdates $1 22 fi 23 fi 13 24 14 # Get Swift Data15 echo "" > $schedulefile16 25 17 #echo "Downloading the schedule for..." 26 18 27 for date in ${dates[@]} 19 28 do 20 #echo " "$date"..." 21 lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date | grep $date >> $schedulefile 29 printprocesslog "INFO getting Swift schedule for the night of "$date 30 echo "INFO getting Swift schedule for the night of "$date 31 # paths and files needed to store schedule 32 date2=`echo $date | sed -e 's/\//-/g'` 33 schedulepath=/home/factwww/scheduling/$date 34 if [ ! -d $schedulepath ] 35 then 36 printprocesslog "WARNING "$schedulingpath" does not exist." 37 echo "WARNING "$schedulingpath" does not exist." 38 continue 39 fi 40 schedulefile=$schedulepath/swift.schedule 41 schedulefile2=$schedulepath/swift.schedule.formated 42 schedulefile3=$schedulepath/swift.schedule.txt 43 44 # overwrite already existing file 45 echo "" > $schedulefile 46 # Get Swift Data 47 # for the date of sunset 48 lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile 49 # for the date of sunrise 50 nextday=`date +%Y-%m-%d --date=$date2"+24hour"` 51 lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile 52 53 # check if schedule is empty 54 checkcontent=`cat $schedulefile` 55 if [ "$checkcontent" = "" ] 56 then 57 printprocesslog "INFO No Schedule found for the night of "$date 58 continue 59 fi 60 61 # grep only the columns which are needed 62 cat $schedulefile | sed -r -e 's/[0-9]{5}\ \ \ [0-9]{1,3}\ \ \ //' | grep -o -E '^\ \ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ [A-Z1-4]([A-Za-z0-9][\ \.\+\-]?){3,20}' > $schedulefile2 63 64 # output list of sources 65 echo -n "Searched the schedule for the following source names: " >$schedulefile3 66 for (( i=0; i<${#sources[@]}; i++ )) 67 do 68 echo -n ${sources[$i]} >>$schedulefile3 69 i2=`echo " $i + 1" | bc -l` 70 if [ $i2 -lt ${#sources[@]} ] 71 then 72 echo -n ", " >>$schedulefile3 73 else 74 echo "" >>$schedulefile3 75 fi 76 done 77 78 printprocesslog "INFO searching the Swift schedule for the following sources: "${sources[@]} 79 # search for source names in schedule file 80 for (( i=0; i<${#sources[@]}; i++ )) 81 do 82 grep "${sources[$i]}" $schedulefile2 >>$schedulefile3 83 done 84 85 # check if a source was found 86 numfound=`cat $schedulefile3 | wc -l` 87 if [ $numfound -eq 1 ] 88 then 89 echo -e "\nNone of the sources was found in the Swift schedule." >> $schedulefile3 90 fi 91 92 # output link to full schedule 93 echo -e "\nThe full schedule can be found <a href='../scheduling/"$date"/"`basename $schedulefile2`"'>here</a>\n" >>$schedulefile3 94 95 printprocesslog "INFO schedule output stored to "$schedulefile3 22 96 done 23 97 24 cat $schedulefile | sed -r -e 's/[0-9]{5}\ \ \ [0-9]{1,3}\ \ \ //' | grep -o -E '^\ \ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ [A-Z1-4]([A-Za-z0-9][\ \.\+\-]?){3,20}' > $schedulefile2 25 26 #echo "" 27 echo -n "Searched the schedule for the following source names: " >$schedulefile3 28 for (( i=0; i<${#sources[@]}; i++ )) 29 do 30 echo -n ${sources[$i]} >>$schedulefile3 31 i2=`echo " $i + 1" | bc -l` 32 if [ $i2 -lt ${#sources[@]} ] 33 then 34 echo -n ", " >>$schedulefile3 35 else 36 echo "" >>$schedulefile3 37 fi 38 done 39 for (( i=0; i<${#sources[@]}; i++ )) 40 do 41 grep "${sources[$i]}" $schedulefile2 >>$schedulefile3 42 done 43 44 echo -e "\nThe full schedule can be found <a href='../scheduling/"$date2"/"`basename $schedulefile2`"'>here</a>\n" >>$schedulefile3 45 98 finish
Note:
See TracChangeset
for help on using the changeset viewer.