source: trunk/DataCheck/Monitoring/CheckSwiftSchedule.sh@ 19422

Last change on this file since 19422 was 19400, checked in by Daniela Dorner, 7 years ago
changed from lynx to links to deal with non-valid certificates
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6
7# list of sources
8sources=( "MRK 421" "Mrk 421" "Mkn 421" "Mkn421" \
9 "1959" "V404" \
10 "1H 0323+342" "RXJ0324.6+3410" "RGBJ0324+3410" "SWIFTJ0325.3-5916"
11 "Crab" "CRAB" \
12 "Mrk 501" "Mkn 501" \
13 "1ES 2344+514" "1ES2344+514" )
14
15# target ids:
16# http://www.swift.ac.uk/swift_live/index.php
17
18# 0323: 90415, 36533, 34137, 35372, 35630
19# http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=1H+0323%2B342&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=1
20
21# Mrk421: 30352, 35014, 215769, 31202, 80050, 31540, 91137, 34228, tbc
22# http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=Mrk+421&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=2
23
24# get dates
25if [ "$certaindate" != "" ]
26then
27 getdates $certaindate
28else
29 if [ "$1" = "" ]
30 then
31 # get next 3 night
32 getdates +3
33 else
34 getdates $1
35 fi
36fi
37
38
39
40for date in ${dates[@]}
41do
42 printprocesslog "INFO getting Swift schedule for the night of "$date
43 #echo "INFO getting Swift schedule for the night of "$date
44 # paths and files needed to store schedule
45 date2=`echo $date | sed -e 's/\//-/g'`
46 schedulepath=/home/factwww/scheduling/$date
47 if [ ! -d $schedulepath ]
48 then
49 printprocesslog "WARNING "$schedulingpath" does not exist."
50 echo "WARNING "$schedulingpath" does not exist."
51 continue
52 fi
53 schedulefile=$schedulepath/swift.schedule
54 schedulefile2=$schedulepath/swift.schedule.formated
55 schedulefile3=$schedulepath/swift.schedule.txt
56
57 # overwrite already existing file
58 echo "" > $schedulefile
59 # Get Swift Data
60 # for the date of sunset
61 printprocesslog "INFO Checking "$date2
62 #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile
63 links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile
64 # for the date of sunrise
65 nextday=`date +%Y-%m-%d --date=$date2"+24hour"`
66 printprocesslog "INFO Checking "$nextday
67 #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile
68 links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile
69
70 # check if schedule is empty
71 checkcontent=`cat $schedulefile`
72 if [ "$checkcontent" = "" ]
73 then
74 printprocesslog "INFO No Schedule found for the night of "$date
75 continue
76 fi
77
78 # grep only the columns which are needed
79 #cat $schedulefile | sed -r -e 's/[0-9]{5,6}[\ ]{1,4}[0-9]{1,3}[\ ]{1,6}//' | grep -o -E '^[\ ]{1,20}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
80 cat $schedulefile | awk '{ print $1" "$2" "$3" "$4" "$7" "$8" "$9}' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}$//' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}\ $//' > $schedulefile2
81
82 # output list of sources
83 echo -n "Searched the schedule for the following source names: " >$schedulefile3
84 for (( i=0; i<${#sources[@]}; i++ ))
85 do
86 echo -n ${sources[$i]} >>$schedulefile3
87 i2=`echo " $i + 1" | bc -l`
88 if [ $i2 -lt ${#sources[@]} ]
89 then
90 echo -n ", " >>$schedulefile3
91 else
92 echo "" >>$schedulefile3
93 fi
94 done
95
96 printprocesslog "INFO searching the Swift schedule for the following sources: "${sources[@]}
97 # search for source names in schedule file
98 for (( i=0; i<${#sources[@]}; i++ ))
99 do
100 grep "${sources[$i]}" $schedulefile2 >>$schedulefile3
101 done
102
103 # check if a source was found
104 numfound=`cat $schedulefile3 | wc -l`
105 if [ $numfound -eq 1 ]
106 then
107 echo -e "\nNone of the sources was found in the Swift schedule." >> $schedulefile3
108 fi
109
110 # output link to full schedule
111 echo -e "\nThe full schedule can be found <a href='../scheduling/"$date"/"`basename $schedulefile2`"'>here</a>\n" >>$schedulefile3
112
113 printprocesslog "INFO schedule output stored to "$schedulefile3
114done
115
116finish
Note: See TracBrowser for help on using the repository browser.